核心就是这三句话
HashAlgorithm algorithm = CryptoConfig.CreateFromName(AlgorithmName);
//通过名字实例化一个加密算法类,比如MD5 SHA1
UTF8Encoding encoding = new UTF8Encoding();//UTF8编码器
string str = Separater.Remove(BitConverter.ToString(algorithm.ComputeHash(encoding.GetBytes(InputStr))), Convert.ToChar("-"));
/*这句比较复杂, 拆开看
*encoding.GetBytes(InputStr),把输入的字符串变成字节码
*algorithm.ComputeHash... 加密并返回字节码
*BitConverter.ToString... 把加密后的字节码转换成字符串
*最后去掉分隔符 "-"
*/
HashAlgorithm algorithm = CryptoConfig.CreateFromName(AlgorithmName);
//通过名字实例化一个加密算法类,比如MD5 SHA1
UTF8Encoding encoding = new UTF8Encoding();//UTF8编码器
string str = Separater.Remove(BitConverter.ToString(algorithm.ComputeHash(encoding.GetBytes(InputStr))), Convert.ToChar("-"));
/*这句比较复杂, 拆开看
*encoding.GetBytes(InputStr),把输入的字符串变成字节码
*algorithm.ComputeHash... 加密并返回字节码
*BitConverter.ToString... 把加密后的字节码转换成字符串
*最后去掉分隔符 "-"
*/
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货