zoukankan      html  css  js  c++  java
  • MD5加密

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Security.Cryptography;
    using System.Text;
    using System.Threading.Tasks;
    
    namespace _01MD5加密
    {
        class Program
        {
            static void Main(string[] args)
            {
                //woaini  woaini
                //202cb962ac59075b964b07152d234b70
               // string s = GetMD5("123");
                //202cb962ac59075b964b07152d234b70
                //202cb962ac59075b964b07152d234b70
                //202cb962ac5975b964b7152d234b70
                //3244185981728979115075721453575112
                //Console.WriteLine(s);
                //Console.ReadKey();
                //double n = 123.456;
                //Console.WriteLine(n.ToString("C"));
                //Console.ReadKey();
            }
    
            public static string GetMD5(string str)
            {
                //创建MD5对象
                MD5 md5 = MD5.Create();
                //开始加密
                //需要将字符处转换成字节数组
                byte[] buffer = Encoding.GetEncoding("GBK").GetBytes(str);
                //返回一个加密好的字节数组
                byte[] MD5Buffer = md5.ComputeHash(buffer);
    
                //将字节数组转换成字符串
                //字节数组---字符串
                //将字节数组中每个元素按照指定的编码格式解析成字符串
                //直接将数组ToString();
                //将字节数组中的每个元素ToString()
              //  return Encoding.GetEncoding("GBK").GetString(MD5Buffer);
    
                // 189 273 345 我爱你
                // 189 273 345
                string strNew = "";
                for (int i = 0; i < MD5Buffer.Length; i++)
                {
                    strNew += MD5Buffer[i].ToString("x2");
                }
                return strNew;
            }
        }
    }
  • 相关阅读:
    Python中的函数介绍
    Python中对文件和目录的操作
    Centos7上vsftp脚本--> sh vsftp.sh 用户名 密码 --> sh vsftp.sh install
    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '***' (2)
    re模块
    模块导入
    装饰器
    内置函数 Ⅱ
    内置函数 Ⅰ
    迭代器、生成器
  • 原文地址:https://www.cnblogs.com/blacop/p/5964889.html
Copyright © 2011-2022 走看看