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


C# SHA384Managed.ComputeHash方法代码示例

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


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

示例1: sha384encrypt

 public static string sha384encrypt(string phrase)
 {
     UTF8Encoding encoder = new UTF8Encoding();
     SHA384Managed sha384hasher = new SHA384Managed();
     byte[] hashedDataBytes = sha384hasher.ComputeHash(encoder.GetBytes(phrase));
     return byteArrayToString(hashedDataBytes);
 }
开发者ID:Ranentil,项目名称:diamonds,代码行数:7,代码来源:Crypto.cs

示例2: 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

示例3: SetKeyButton_Click

 private void SetKeyButton_Click(object sender, EventArgs e)
 {
     var passwordBytes = Encoding.ASCII.GetBytes(PasswordBox.Text);
     SHA384 sha = new SHA384Managed();
     _cryptor.Key = sha.ComputeHash(passwordBytes);
     EncryptButton.Enabled = true;
     DecryptButton.Enabled = false;
 }
开发者ID:Shanis47,项目名称:MARS_cryptoalgorithm,代码行数:8,代码来源:Cryptor.cs

示例4: SHA384

 public static string SHA384(string data)
 {
     byte[] hash;
     using (SHA384 shaM = new SHA384Managed())
     {
         hash = shaM.ComputeHash(data.GetBytes());
     }
     return AESProvider.HexString(hash);
 }
开发者ID:exaphaser,项目名称:PowerCrypt4,代码行数:9,代码来源:HashUtils.cs

示例5: 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

示例6: Sha384

        public static string Sha384(string msg)
        {
            if (msg == null)
                return null;

            var encoder = new UTF8Encoding();
            var sha384Hasher = new SHA384Managed();
            var hashedDataBytes = sha384Hasher.ComputeHash(encoder.GetBytes(msg));

            return ByteArrayToString(hashedDataBytes);
        }
开发者ID:kirkpabk,项目名称:higgs,代码行数:11,代码来源:HashFunction.cs

示例7: SHA384Hash

 public static string SHA384Hash(string Paragraph)
 {
     SHA384 sha = new SHA384Managed();
     byte[] hash = sha.ComputeHash(Encoding.ASCII.GetBytes(Paragraph));
     StringBuilder sb = new StringBuilder();
     foreach (byte bt in hash)
     {
         sb.AppendFormat("{0:x2}", bt);
     }
     return sb.ToString();
 }
开发者ID:Celestias,项目名称:CSharp-Tools,代码行数:11,代码来源:Form1.cs

示例8: 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

示例9: SHA384Hash

        /// <summary>
        /// Encrypts a string using the SHA384(Secure Hash Algorithm) algorithm.
        /// This works in the same manner as MD5, providing 384bit encryption.
        /// </summary>
        /// <param name="Data">A string containing the data to encrypt.</param>
        /// <returns>A string containing the string, encrypted with the SHA384 algorithm.</returns>
        public static string SHA384Hash(string Data)
        {
            SHA384 sha = new SHA384Managed();
            byte[] hash = sha.ComputeHash(Encoding.ASCII.GetBytes(Data));

            StringBuilder stringBuilder = new StringBuilder();
            foreach (byte b in hash)
            {
                stringBuilder.AppendFormat("{0:x2}", b);
            }
            return stringBuilder.ToString();
        }
开发者ID:BGCX262,项目名称:zynchronyze-svn-to-git,代码行数:18,代码来源:CryptoHelper.cs

示例10: RijndaelEncryptor

        public RijndaelEncryptor()
        {
            m_key = new byte[32];
            m_vector = new byte[16];

            using (var sha = new SHA384Managed())
            {
                byte[] hashArray = sha.ComputeHash(hashBuffer);

                Array.Copy(hashArray, 0, m_key, 0, 32);
                Array.Copy(hashArray, 32, m_vector, 0, 16);
            }
        }
开发者ID:dstarosta,项目名称:GitProjects,代码行数:13,代码来源:RijndealEncryptor.cs

示例11: GetSHA384

        public static String GetSHA384(String strPlain)
        {
            UnicodeEncoding UE = new UnicodeEncoding();
            Byte[] HashValue, MessageBytes = UE.GetBytes(strPlain);
            SHA384Managed SHhash = new SHA384Managed();
            String strHex = String.Empty;

            HashValue = SHhash.ComputeHash(MessageBytes);
            foreach (Byte b in HashValue)
            {
                strHex += String.Format("{0:x2}", b);
            }
            return strHex;
        }
开发者ID:paulweatherby,项目名称:Trust,代码行数:14,代码来源:Hasher.cs

示例12: Encrypt

        /// <summary>
        /// Encrypts the specified value.
        /// </summary>
        /// <param name="value">The value.</param>
        /// <param name="includeTag">if set to <c>true</c> include the module Tag.</param>
        /// <returns>
        /// The encrypted hash.
        /// </returns>
        /// <exception cref="Haxxor.Framework.Core.Exceptions.HaxxorException">Value cannot be null when encrypting.</exception>
        public override string Encrypt(string value, bool includeTag = true)
        {
            if (value == null)
            {
                throw new HaxxorException("Value cannot be null when encrypting.");
            }

            var bytes = CryptoHelper.GetBytes(value);

            using (var sha = new SHA384Managed())
            {
                var hash = sha.ComputeHash(bytes);
                var hash64 = Convert.ToBase64String(hash);

                return includeTag
                    ? CryptoHelper.FormatTagHash(Tag, hash64)
                    : hash64;
            }
        }
开发者ID:Badgerati,项目名称:Haxxor,代码行数:28,代码来源:SHA384EncryptionModule.cs

示例13: GenerateKey

        /*****************************************************************
         * Generate an encryption key based on the given phrase.  The 
         * phrase is hashed to create a unique 32 character (256-bit) 
         * value, of which 24 characters (192 bit) are used for the
         * key and the remaining 8 are used for the initialization 
         * vector (IV).
         * 
         * Parameters:  SecretPhrase - phrase to generate the key and 
         * IV from.
         * 
         * Return Val:  None  
         ***************************************************************/
        private void GenerateKey(string SecretPhrase)
        {
            // Initialize internal values
            this._Key = new byte[24];
            this._IV = new byte[16];

            // Perform a hash operation using the phrase.  This will 
            // generate a unique 32 character value to be used as the key.
            byte[] bytePhrase = Encoding.ASCII.GetBytes(SecretPhrase);
            SHA384Managed sha384 = new SHA384Managed();
            sha384.ComputeHash(bytePhrase);
            byte[] result = sha384.Hash;

            // Transfer the first 24 characters of the hashed value to the key
            // and the remaining 8 characters to the intialization vector.
            for (int loop = 0; loop < 24; loop++) this._Key[loop] = result[loop];
            for (int loop = 24; loop < 40; loop++) this._IV[loop - 24] = result[loop];
        }
开发者ID:Avaruz,项目名称:Avaruz.FrameWork,代码行数:30,代码来源:EncryptDecrypt.cs

示例14: FileSHA384

 public static string FileSHA384(string fileName)
 {
     StringBuilder formatted;
     using (var fs = File.OpenRead(fileName))
     using (var bs = new BufferedStream(fs))
     {
         using (SHA384 sha384 = new SHA384Managed())
         {
             var hash = sha384.ComputeHash(bs);
             formatted = new StringBuilder(2 * hash.Length);
             foreach (var b in hash)
             {
                 formatted.AppendFormat("{0:x2}", b);
             }
         }
     }
     return formatted.ToString();
 }
开发者ID:zdimension,项目名称:SharpBoot,代码行数:18,代码来源:Utils.cs

示例15: GenerateKey

        private void GenerateKey(string password)
        {
            SHA384Managed sha = new SHA384Managed();
            byte[] b = sha.ComputeHash(new ASCIIEncoding().GetBytes(password));

            Key = new byte[32];
            Vector = new byte[16];

            Array.Copy(b, 0, Key, 0, 32);
            Array.Copy(b, 32, Vector, 0, 16);
        }
开发者ID:remcomulder,项目名称:Alien-Invasion-Coding-Challenge,代码行数:11,代码来源:SymmetricEncryption.cs


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