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

    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Security.Cryptography;

    namespace Qifan.Common
    {
        
    /// <summary>
        
    /// 加密/解密字符串
        
    /// </summary>

        public class Security
        
    {
            
    /// <summary>
            
    /// MD5 加密
            
    /// </summary>
            
    /// <param name="passWord">需要加密的字符串</param>
            
    /// <returns>加密后的字符串</returns>

            public static string Md5(string passWord)
            
    {
                Byte[] clearBytes 
    = new UnicodeEncoding().GetBytes(passWord);
                Byte[] hashedBytes 
    = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
                
    return BitConverter.ToString(hashedBytes);
            }


            
    /// <summary>
            
    /// SHA1 加密
            
    /// </summary>
            
    /// <param name="passWord">需要加密的字符串</param>
            
    /// <returns>加密后的字符串</returns>

            public static string Sha1(string passWord)
            
    {
                Byte[] clearBytes 
    = new UnicodeEncoding().GetBytes(passWord);
                Byte[] hashedBytes 
    = ((HashAlgorithm)CryptoConfig.CreateFromName("SHA1")).ComputeHash(clearBytes);
                
    return BitConverter.ToString(hashedBytes);
            }

        }

    }
  • 相关阅读:
    字符串哈希
    codeforces#766 D. Mahmoud and a Dictionary (并查集)
    莫比乌斯反演模板
    马拉车模板
    codeforces#580 D. Kefa and Dishes(状压dp)
    1076E
    448C
    543A
    295B
    poj3974 Palindrome
  • 原文地址:https://www.cnblogs.com/yangbin1005/p/1156996.html
Copyright © 2011-2022 走看看