- Home /
Assets/_Scripts/Md5.cs(1,15): error CS0116: A namespace can only contain types and namespace declarations
hi i am trying to create a server side high score and i am already on the Md5 part, i got the Md5 code from here: link text, and I'm using C# this is my actual code:
using UnityEngine;
using System.Collections;
//public class Md5 : MonoBehaviour {
public string Md5Sum(string strToEncrypt)
{
System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding();
byte[] bytes = ue.GetBytes(strToEncrypt);
// encrypt bytes
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] hashBytes = md5.ComputeHash(bytes);
// Convert the encrypted bytes back to a string (base 16)
string hashString = "";
for (int i = 0; i < hashBytes.Length; i++)
{
hashString += System.Convert.ToString(hashBytes[i], 16).PadLeft(2, '0');
}
return hashString.PadLeft(32, '0');
}
//S}
--this is the actual code i have on my Md5 C# file in unity and i am getting that error and i really don't know what to do the site says that it is "Best placed in your static-only utility class." am i doing it wrong?, how do i fix this?, how can i make this a static-only utility class?.
i really need some help here.
If you have commented out line 4 and 24 in your script, you do not have a class only. :/
If you dont want it to be a monobehaviour, which I think is what you intend to do, simply change this
public class $$anonymous$$d5 : $$anonymous$$onoBehaviour {
to
public class $$anonymous$$d5 {
and uncomment the curly brace at line 24.