C# MD5 应用


  1.         public String md5(String s)
  2.         {
  3.             System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
  4.             byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s);
  5.             bytes = md5.ComputeHash(bytes);
  6.             md5.Clear();
  7.             string ret = "";
  8.             for (int i = 0; i < bytes.Length; i++)
  9.             {
  10.                 ret += Convert.ToString(bytes[i], 16).PadLeft(2, '0');
  11.             }
  12.             return ret.PadLeft(32, '0');
  13.         }

posted @   星火燎猿*  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 微软正式发布.NET 10 Preview 1:开启下一代开发框架新篇章
· C# 集成 DeepSeek 模型实现 AI 私有化(本地部署与 API 调用教程)
· DeepSeek R1 简明指南:架构、训练、本地部署及硬件要求
· NetPad:一个.NET开源、跨平台的C#编辑器
· 面试官:你是如何进行SQL调优的?
点击右上角即可分享
微信分享提示