C#调用Java MD5加密 转换成base64编码

public byte[] GetUTF8(string content)
{
byte[] bytes = Encoding.UTF8.GetBytes(content);
return bytes;
}

public byte[] GetHash(byte[] sources)
{
MD5CryptoServiceProvider MD5CSP = new MD5CryptoServiceProvider();
byte[] targets = MD5CSP.ComputeHash(sources);
return targets;
}

public string ConvertBase64(byte[] sources)
{
string value = Convert.ToBase64String(sources);
return value;
}

string body="hello234";

string data_digest = ConvertBase64(GetHash(GetUTF8(body + "key123")));

posted @ 2023-08-03 11:49  懂你++  阅读(88)  评论(0)    收藏  举报