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);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hash.Length; i++)
{
sb.Append(hash[i].ToString("X2"));//大 "X2",小"x2"
}
return sb.ToString();
}
DES加密的方法:
public static string EncryptDES(string encryptString, string encryptKey)
{
try
{
byte[] rgbKey = Encoding.UTF8.GetBytes(encryptKey.Substring(0, 8));
byte[] rgbIV = Keys;
byte[] inputByteArray = Encoding.UTF8.GetBytes(encryptString);
DESCryptoServiceProvider dCSP = new DESCryptoService
Unity中MD5与DES加密解密实战

本文介绍了在Unity引擎中如何实现MD5和DES两种加密方式,包括MD5的不可逆加密过程,以及DES的加密和解密方法,为游戏数据的安全存储提供基础支持。
最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



