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


C# SHA384Managed.Clear方法代码示例

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


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

示例1: SHA384Encrypt

 /// <summary>
 /// SHA384加密,不可逆转
 /// </summary>
 /// <param name="str">string str:被加密的字符串</param>
 /// <returns>返回加密后的字符串</returns>
 public string SHA384Encrypt(string str)
 {
     System.Security.Cryptography.SHA384 s384 = new System.Security.Cryptography.SHA384Managed();
     byte[] byte1;
     byte1 = s384.ComputeHash(Encoding.UTF8.GetBytes(str));
     s384.Clear();
     return Convert.ToBase64String(byte1);
 }
开发者ID:lxh2014,项目名称:gigade-net,代码行数:13,代码来源:HashEncrypt.cs

示例2: SHA384Compute

        public static byte[] SHA384Compute(byte[] data)
        {
            if (data == null)
                throw new ArgumentNullException("data");

            SHA384Managed SHA384 = new SHA384Managed();
            byte[] hash = SHA384.ComputeHash(data);
            SHA384.Clear();
            return hash;
        }
开发者ID:Steeslice,项目名称:StealthNet-Alt,代码行数:10,代码来源:ComputeHashes.cs

示例3: FromString

        public static string FromString(string input, HashType hashtype)
        {
            Byte[] clearBytes;
            Byte[] hashedBytes;
            string output = String.Empty;

            switch (hashtype)
            {
                case HashType.RIPEMD160:
                    clearBytes = new UTF8Encoding().GetBytes(input);
                    RIPEMD160 myRIPEMD160 = RIPEMD160Managed.Create();
                    hashedBytes = myRIPEMD160.ComputeHash(clearBytes);
                    output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
                    break;
                case HashType.MD5:
                    clearBytes = new UTF8Encoding().GetBytes(input);
                    hashedBytes = ((HashAlgorithm)CryptoConfig.CreateFromName("MD5")).ComputeHash(clearBytes);
                    output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
                    break;
                case HashType.SHA1:
                    clearBytes = Encoding.UTF8.GetBytes(input);
                    SHA1CryptoServiceProvider sha1 = new SHA1CryptoServiceProvider();
                    sha1.ComputeHash(clearBytes);
                    hashedBytes = sha1.Hash;
                    sha1.Clear();
                    output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
                    break;
                case HashType.SHA256:
                    clearBytes = Encoding.UTF8.GetBytes(input);
                    SHA256 sha256 = new SHA256Managed();
                    sha256.ComputeHash(clearBytes);
                    hashedBytes = sha256.Hash;
                    sha256.Clear();
                    output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
                    break;
                case HashType.SHA384:
                    clearBytes = Encoding.UTF8.GetBytes(input);
                    SHA384 sha384 = new SHA384Managed();
                    sha384.ComputeHash(clearBytes);
                    hashedBytes = sha384.Hash;
                    sha384.Clear();
                    output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
                    break;
                case HashType.SHA512:
                    clearBytes = Encoding.UTF8.GetBytes(input);
                    SHA512 sha512 = new SHA512Managed();
                    sha512.ComputeHash(clearBytes);
                    hashedBytes = sha512.Hash;
                    sha512.Clear();
                    output = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();
                    break;
            }
            return output;
        }
开发者ID:nguyenhaiquan,项目名称:trade-software,代码行数:54,代码来源:hashing.cs


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