当前位置: 首页>>代码示例>>C#>>正文


C# System.Security.Cryptography.SHA1CryptoServiceProvider.Clear方法代码示例

本文整理汇总了C#中System.Security.Cryptography.SHA1CryptoServiceProvider.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# System.Security.Cryptography.SHA1CryptoServiceProvider.Clear方法的具体用法?C# System.Security.Cryptography.SHA1CryptoServiceProvider.Clear怎么用?C# System.Security.Cryptography.SHA1CryptoServiceProvider.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Security.Cryptography.SHA1CryptoServiceProvider的用法示例。


在下文中一共展示了System.Security.Cryptography.SHA1CryptoServiceProvider.Clear方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EncryptToSHA1

 public string EncryptToSHA1(string str)
 {
     System.Security.Cryptography.SHA1CryptoServiceProvider sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] str1 = System.Text.Encoding.UTF8.GetBytes(str);
     byte[] str2 = sha1.ComputeHash(str1);
     sha1.Clear();
     (sha1 as IDisposable).Dispose();
     return Convert.ToBase64String(str2);
 }
开发者ID:iCnG,项目名称:myGitHub,代码行数:9,代码来源:Default.aspx.cs

示例2: Encriptar

 public static string Encriptar(string valor)
 {
     string clave;
     System.Security.Cryptography.SHA1CryptoServiceProvider provider = new System.Security.Cryptography.SHA1CryptoServiceProvider();
     byte[] bytes = System.Text.Encoding.UTF8.GetBytes(valor);
     byte[] inArray = provider.ComputeHash(bytes);
     provider.Clear();
     clave = Convert.ToBase64String(inArray);
     return clave;
 }
开发者ID:paul33868,项目名称:Seguridad,代码行数:10,代码来源:cEncriptacion.cs

示例3: encrypt

        /// <summary>
        /// Método para encriptar un string. En este caso se usa para el Pass.
        /// </summary>
        /// <param name="password">Contraseña a encriptar</param>
        /// <returns>Cadena encriptada</returns>
        private static string encrypt(string password)
        {
            System.Security.Cryptography.HashAlgorithm hashValue = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            byte[] bytes = System.Text.Encoding.UTF8.GetBytes(password);
            byte[] byteHash = hashValue.ComputeHash(bytes);

            hashValue.Clear();

            return (Convert.ToBase64String(byteHash));
        }
开发者ID:TatianaRadkevich,项目名称:implementacion-proyectofinal2011,代码行数:15,代码来源:Usuario.cs

示例4: SHA1_Real

        public static string SHA1_Real(string data)
        {
            // Hash the input string using SHA1 and output a hexadecimal answer
            byte[] bdata = System.Text.ASCIIEncoding.ASCII.GetBytes(data);
            byte[] result = null;

            System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            result = sha.ComputeHash(bdata);

            sha.Clear();

            string result_s = "";

            foreach(byte b in result)
                result_s += String.Format("{0:x2}", b);

            return result_s;
        }
开发者ID:Bloodknight,项目名称:TorqueDev,代码行数:18,代码来源:CConfig.cs

示例5: SHA1

        public static string SHA1(string data)
        {
            // Hash the input string using SHA1 and output a base64 answer

            byte[] bdata = System.Text.ASCIIEncoding.ASCII.GetBytes(data);
            byte[] result = null;

            System.Security.Cryptography.SHA1 sha = new System.Security.Cryptography.SHA1CryptoServiceProvider();
            result = sha.ComputeHash(bdata);

            sha.Clear();

            return Convert.ToBase64String(result);
        }
开发者ID:Bloodknight,项目名称:TorqueDev,代码行数:14,代码来源:CConfig.cs

示例6: Hash_SHA_1

        /// <summary>
        /// 计算SHA-1码
        /// </summary>
        /// <param name="word">字符串</param>
        /// <param name="toUpper">返回哈希值格式 true:英文大写,false:英文小写</param>
        /// <returns></returns>
        public static string Hash_SHA_1(string word, bool toUpper = true)
        {
            try
            {
                System.Security.Cryptography.SHA1CryptoServiceProvider SHA1CSP
                    = new System.Security.Cryptography.SHA1CryptoServiceProvider();

                byte[] bytValue = System.Text.Encoding.UTF8.GetBytes(word);
                byte[] bytHash = SHA1CSP.ComputeHash(bytValue);
                SHA1CSP.Clear();

                //根据计算得到的Hash码翻译为SHA-1码
                string sHash = "", sTemp = "";
                for (int counter = 0; counter < bytHash.Count(); counter++)
                {
                    long i = bytHash[counter] / 16;
                    if (i > 9)
                    {
                        sTemp = ((char)(i - 10 + 0x41)).ToString();
                    }
                    else
                    {
                        sTemp = ((char)(i + 0x30)).ToString();
                    }
                    i = bytHash[counter] % 16;
                    if (i > 9)
                    {
                        sTemp += ((char)(i - 10 + 0x41)).ToString();
                    }
                    else
                    {
                        sTemp += ((char)(i + 0x30)).ToString();
                    }
                    sHash += sTemp;
                }

                //根据大小写规则决定返回的字符串
                return toUpper ? sHash : sHash.ToLower();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
开发者ID:cqingyu,项目名称:CSharpPubLib,代码行数:50,代码来源:HashHelper.cs


注:本文中的System.Security.Cryptography.SHA1CryptoServiceProvider.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。