unity 中对MD5的加密

    xiaoxiao2021-03-25  166

    【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(); }

    转载请注明原文地址: https://ju.6miu.com/read-7202.html

    最新回复(0)