博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
asp.neti 加密三种方式
阅读量:4583 次
发布时间:2019-06-09

本文共 1501 字,大约阅读时间需要 5 分钟。

public string Get_MD5_Method1(string strSource)        {            System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();            //获取密文字节数组             byte[] bytResult = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(strSource));            //转换成字符串,并取9到25位             string strResult = BitConverter.ToString(bytResult, 4, 8);            //转换成字符串,32位             //string strResult = BitConverter.ToString(bytResult);             //BitConverter转换出来的字符串会在每个字符中间产生一个分隔符,需要去除掉             strResult = strResult.Replace("-", "");            return strResult;         }--------------------------------------------第二种  public string Get_MD5_Method2(string strSource)        {            string strResult = "";            //Create             System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();            //注意编码UTF8、UTF7、Unicode等的选择             byte[] bytResult = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(strSource));            //字节类型的数组转换为字符串             for (int i = 0; i < bytResult.Length; i++)            {                //16进制转换                 strResult = strResult + bytResult[i].ToString("X");            }            return strResult;        } -------------------------简写--------------public string Get_MD5_Method3(string strSource) {  return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strSource, "MD5"); }

 

转载于:https://www.cnblogs.com/codemouserman/p/4283815.html

你可能感兴趣的文章
Int..的范围
查看>>
HDU 2585 [Hotel]字符串递归处理
查看>>
ffmpeg 编码h264 profile如何设置为baseline的问题
查看>>
CSharper 学Quick-Cocos2d-X (一) 开发环境的搭建
查看>>
PoolThreadCache
查看>>
使grub4dos引导启动linux
查看>>
P2597 [ZJOI2012]灾难
查看>>
LeetCode--LinkedList--206. Reverse Linked List(Easy)
查看>>
最短路径
查看>>
Console-算法[for,if]-一水仙花数(Water flower)
查看>>
IntelliJ-IDEA和Git、GitHub、Gitlab的使用
查看>>
Request——Node世界中被依赖最多的库No.2
查看>>
【共读Primer】26.[4.6]成员访问运算符 Page133
查看>>
8、OpenCV Python 图像直方图
查看>>
判断远程主机是否存在某个文件
查看>>
[SDOI2011]工作安排
查看>>
block change tracking buffer space
查看>>
简单API练手:(1)复制自身程序到windows目录和系统目录下;(2)获得系统的相关信息。...
查看>>
codeforces 722D Generating Sets 【优先队列】
查看>>
【并发编程】延时初始化
查看>>