我在WPF应用程序中使用了以下代码:
public static string EncryptString(string stringToEncrypt)
{
SHA256 hash = SHA256.Create();
byte[] stringHash = System.Text.Encoding.ASCII.GetBytes(stringToEncrypt);
byte[] encryptedString = hash.ComputeHash(stringHash);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < encryptedString.Length; i++)
sb.Append(encryptedString[i].ToString("X2"));
return sb.ToString();
}但它在Windows Phone 7上不起作用(SHA256无法识别Windows)。
发布于 2012-03-28 23:57:48
您必须使用MSDN上记录的Silverlight SHA256 version。蓝色的手机图标标记了Windows phone 7上可用的成员。
要创建实例,您必须直接调用托管实现的构造函数:
var hash = new SHA256Managed();https://stackoverflow.com/questions/9911229
复制相似问题