示例#1
0
    // Use this for initialization
    void Start()
    {
        string txt = "txtbuild";
        string key = "smkdd";

        // md5
        Debug.Log(MD5Encrypter.BuildStringMD5(txt));
        // sha1
        Debug.Log(SHAEncrypter.SHA1Encrypt(txt));
        // des
        string desTxt = DESEncrypter.Encrypt(txt, key);

        Debug.Log(desTxt);
        Debug.Log(DESEncrypter.Decrypt(desTxt, key) == txt);
    }
示例#2
0
        public void Login(LoginInfo info)
        {
            User user = GetByName(info.UserName);

            if (user != null)
            {
                if (info.IsEncrypted)
                {
                    if (MD5Encrypter.MD5Encrypt32(user.Password) == info.Password)
                    {
                        info.SetSuccess(user.Authority);
                    }
                    else
                    {
                        info.Result = false;
                    }
                }
                else
                {
                    if (info.Password == user.Password)
                    {
                        info.SetSuccess(user.Authority);
                    }
                    else
                    {
                        info.Result = false;
                    }
                }

                SetUser(user, info);
            }
            else
            {
                info.Result = false;
            }
        }
示例#3
0
    // manda encriptar los datos guardados
    private string Encrypt(string file)
    {
        string firstHash = MD5Encrypter.Md5Sum(file);

        return(MD5Encrypter.Md5Sum(hashHeader + firstHash));
    }