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);
            }

        }

    }
  • 相关阅读:
    08day 操作命令以及目录结构
    换工作
    json转为字典
    快速排序
    冒泡排序
    python函数-生成器
    关键字global
    函数的定义和参数调用
    count()函数与center()函数
    python字符串常用函数:strip()
  • 原文地址:https://www.cnblogs.com/yangbin1005/p/1156996.html
Copyright © 2011-2022 走看看