• C#中采用SHA1或MD5加密字符串的函数


    #region 获取由SHA1加密的字符串
    public string EncryptToSHA1(string str)
    {
                SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
                byte[] str1 = Encoding.UTF8.GetBytes(str);
                byte[] str2 = sha1.ComputeHash(str1);
                sha1.Clear();
                (sha1 as IDisposable).Dispose();
                return Convert.ToBase64String(str2);
    }
    #endregion
    #region 获取由MD5加密的字符串
    public string EncryptToMD5(string str)
    {
                MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
                byte[] str1 = Encoding.UTF8.GetBytes(str);
                byte[] str2 = md5.ComputeHash(str1, 0, str1.Length);
                md5.Clear();
                (md5 as IDisposable).Dispose();
                return Convert.ToBase64String(str2);
    }
    #endregion
  • 相关阅读:
    InterLockedIncrement and InterLockedDecrement
    bzoj2763
    bzoj1922
    bzoj1705
    bzoj1040
    bzoj3039
    bzoj1801
    bzoj2565
    bzoj1976
    一类最小割bzoj2127,bzoj2132 bzoj3438
  • 原文地址:https://www.cnblogs.com/szytwo/p/2990022.html
Copyright © 2020-2023  润新知