unity 中对MD5的加密

来源:互联网 发布:excuse me网络用语缩写 编辑:程序博客网 时间:2024/06/08 17:34

【MD5】在向服务器SendMessage 时 对密码进行MD5处理,由于MD5的不可逆性,只有通过撞库来解密。而且在UNITY中可以通过对比MD5来判断版本进行强制更新等,这是unity中C#进行MD5加密代码

  public string Md5Sum(string input)    {        System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();        byte[] inputBytes = System.Text.Encoding.ASCII.GetBytes(input);        byte[] hash = md5.ComputeHash(inputBytes);        System.Text.StringBuilder sb = new System.Text.StringBuilder();        for (int i = 0; i < hash.Length; i++)        {            sb.Append(hash[i].ToString("x2"));        }        return sb.ToString();    }


0 0