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 ConsoleApplication1
    {
    class Program
    {
    static void Main(string[] args)
    { string str1 = Console.ReadLine();

    string sr = Clas.MD5Encrypt(str1);
    Console.WriteLine(sr);

    string f = Clas.MD5(sr);
    Console.WriteLine(f);
    Console.ReadLine();

    }

    static string myMD5(string str)
    {
    string pwd = "";
    MD5 md5 = new MD5CryptoServiceProvider();
    Byte[] byt = md5.ComputeHash(Encoding.Unicode.GetBytes(str));
    for (int i = 0; i < byt.Length; i++)
    {
    pwd += byt[i].ToString("x");
    }
    return pwd;
    }
    /// <summary>
    /// MD5 加密(不可逆加密)
    /// </summary>
    /// <param name="pass">要加密的原始字串</param>
    /// <returns></returns>
    public static string MD5Encrypt(string pass)
    {
    System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
    byte[] bytResult = md5.ComputeHash(System.Text.Encoding.UTF8.GetBytes(pass));
    md5.Clear();
    string strResult = BitConverter.ToString(bytResult);
    strResult = strResult.Replace("-", "");
    return strResult;
    }

    public static string MD5 (this string text)
    {
    return FormsAuthentication.HashPasswordForStoringInConfigFile (text, "md5");
    }


    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "SHA")]
    public static string SHA1 (this string text)
    {
    return FormsAuthentication.HashPasswordForStoringInConfigFile (text, "sha1");
    }

  • 相关阅读:
    There was an internal API error
    MD5加密
    CentOS 7 最小化安装简单配置
    Dalvik 虚拟机操作码
    BugkuCTF~Web~WriteUp
    BugkuCTF~代码审计~WriteUp
    Android 个人手机通讯录开发
    Android SQLite 数据库学习
    Android 程序结构
    2018~第三届南宁市网络安全技术大赛~nnctf~write-up
  • 原文地址:https://www.cnblogs.com/BoYu045535/p/3682722.html
Copyright © 2011-2022 走看看