c# md5 加密

复制代码
 1   public class MD5Utils
 2 {
 3     public string ComputeHash(string input)
 4     {
 5         using (MD5 md5 = MD5.Create())
 6         {
 7             // 将输入字符串转换为字节数组
 8             byte[] inputBytes = Encoding.UTF8.GetBytes(input);
 9 
10             // 计算 MD5 哈希值
11             byte[] hashBytes = md5.ComputeHash(inputBytes);
12 
13             // 将字节数组转换为十六进制字符串
14             StringBuilder sb = new StringBuilder();
15             for (int i = 0; i < hashBytes.Length; i++)
16             {
17                 sb.Append(hashBytes[i].ToString("x2"));
18             }
19 
20             return sb.ToString();
21         }
22     }
23 }
复制代码

 

posted @   赵三毛  阅读(15)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构

喜欢请打赏

扫描二维码打赏

支付宝打赏

点击右上角即可分享
微信分享提示