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


C# HashAlgorithm.GetType方法代码示例

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


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

示例1: HashEncryptor

        /// <summary>
        /// 지정된 HashAlgorithm을 이용하는 HashEncryptor를 생성합니다.
        /// </summary>
        /// <param name="algorithm"></param>
        public HashEncryptor(HashAlgorithm algorithm) {
            algorithm.ShouldNotBeNull("algorithm");
            Algorithm = algorithm;

            if(IsDebugEnabled)
                log.Debug("Hash 계산을 위해 HashEncryptor를 생성합니다... Algorithm=[{0}]", algorithm.GetType().FullName);
        }
开发者ID:debop,项目名称:NFramework,代码行数:11,代码来源:HashEncryptor.cs

示例2: Get

        public static string Get(HashAlgorithm algo)
        {
            if (algo is SHA1)
                return "SHA1";
            if (algo is SHA256)
                return "SHA256";
            if (algo is SHA384)
                return "SHA384";
            if (algo is SHA512)
                return "SHA512";
            if (algo is MD5)
                return "MD5";
            if (algo is RIPEMD160)
                return "RIPEMD160";

            throw new UnknownAlgorithmException("uncatched algorithm " + algo.GetType());
        }
开发者ID:Gurkenschreck,项目名称:Cipha,代码行数:17,代码来源:OIDIdentifier.cs

示例3: map_hash_algorithm

        // Map a HashAlgorithm object to our HASH_ALGORITHM enumeration
        HASH_ALGORITHM map_hash_algorithm(HashAlgorithm hasher)
        {
            Type t = hasher.GetType();

            if (Object.ReferenceEquals(t, typeof(MD5CryptoServiceProvider)))
                return HASH_ALGORITHM.RSA_MD5;
            if (Object.ReferenceEquals(t, typeof(SHA1CryptoServiceProvider)))
                return HASH_ALGORITHM.RSA_SHA1;
            throw new ArgumentException("unknown HashAlgorithm");
        }
开发者ID:dnnsharp,项目名称:DynamicRotator,代码行数:11,代码来源:ezrsa.cs

示例4: GenerateHash

        /// <summary>
        ///     Get the hash value of the assembly when hashed with a specific algorithm.  The actual hash
        ///     algorithm object is not used, however the same type of object will be used.
        /// </summary>
        public byte[] GenerateHash(HashAlgorithm hashAlg)
        {
            if (hashAlg == null)
                throw new ArgumentNullException("hashAlg");
            Contract.EndContractBlock();

            byte[] hashValue = GenerateHash(hashAlg.GetType());

            byte[] returnHash = new byte[hashValue.Length];
            Array.Copy(hashValue, returnHash, returnHash.Length);
            return returnHash;
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:16,代码来源:hash.cs

示例5: GenerateHash

 public byte[] GenerateHash(HashAlgorithm hashAlg)
 {
     if (hashAlg == null)
     {
         throw new ArgumentNullException("hashAlg");
     }
     byte[] sourceArray = this.GenerateHash(hashAlg.GetType());
     byte[] destinationArray = new byte[sourceArray.Length];
     Array.Copy(sourceArray, destinationArray, destinationArray.Length);
     return destinationArray;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:Hash.cs

示例6: Hash

        static HashResult Hash(byte[] text, byte[] salt, HashAlgorithm algorithm)
        {
            if (text == null || text.Length == 0)
                return null;
            if (salt == null || salt.Length < SALT_LENGTH)
                throw new ArgumentException("Must be atleast " + SALT_LENGTH.ToString() + " characters in length", "salt");

            // Het hashingalgoritme verwacht bytes. Converteer onze string naar bytes
            var bytesUnhashed = text.Concat(salt).ToArray();

            // Magic time
            var hash = algorithm.ComputeHash(bytesUnhashed);

            // Transformeer de salt en de hash naar een Base-64 encoded string zodat je deze gemakkelijk kan opslaan en opsturen
            return new HashResult(algorithm.GetType().Name, Convert.ToBase64String(salt), Convert.ToBase64String(hash));
        }
开发者ID:PerplexInternetmarketing,项目名称:PerplexMail-for-Umbraco,代码行数:16,代码来源:Security.cs

示例7: TestHash

        private static void TestHash(HashAlgorithm hashAlgorithm, int count, int size)
        {
            // Create test string of relevant length.
            Random random = new Random();

            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            for (int i = 0; i < count; i++)
            {
                StringBuilder sb = new StringBuilder();
                for (int a = 0; a < size; a++)
                    sb.Append(CharacterPool[(int) (random.NextDouble() * CharacterPool.Length)]);

                string testString = sb.ToString();
                GetHash(hashAlgorithm, testString);
            }
            stopwatch.Stop();
            Trace.WriteLine(
                string.Format(
                    "{1}ms\t{2} chars x {3}\t{0}",
                    hashAlgorithm.GetType(),
                    stopwatch.ElapsedTicks * 1000 / Stopwatch.Frequency,
                    size,
                    count));
        }
开发者ID:webappsuk,项目名称:CoreLibraries,代码行数:25,代码来源:TestHashing.cs

示例8: LogVerifySignedInfo

 internal static void LogVerifySignedInfo(SignedXml signedXml, AsymmetricAlgorithm key, SignatureDescription signatureDescription, HashAlgorithm hashAlgorithm, AsymmetricSignatureDeformatter asymmetricSignatureDeformatter, byte[] actualHashValue, byte[] signatureValue)
 {
     if (InformationLoggingEnabled)
     {
         string data = string.Format(CultureInfo.InvariantCulture, SecurityResources.GetResourceString("Log_VerifySignedInfoAsymmetric"), new object[] { GetKeyName(key), signatureDescription.GetType().Name, hashAlgorithm.GetType().Name, asymmetricSignatureDeformatter.GetType().Name });
         WriteLine(signedXml, TraceEventType.Information, SignedXmlDebugEvent.VerifySignedInfo, data);
     }
     if (VerboseLoggingEnabled)
     {
         string str2 = string.Format(CultureInfo.InvariantCulture, SecurityResources.GetResourceString("Log_ActualHashValue"), new object[] { FormatBytes(actualHashValue) });
         WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, str2);
         string str3 = string.Format(CultureInfo.InvariantCulture, SecurityResources.GetResourceString("Log_RawSignatureValue"), new object[] { FormatBytes(signatureValue) });
         WriteLine(signedXml, TraceEventType.Verbose, SignedXmlDebugEvent.VerifySignedInfo, str3);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:SignedXmlDebugLog.cs

示例9: LogSigning

 internal static void LogSigning(SignedXml signedXml, object key, SignatureDescription signatureDescription, HashAlgorithm hash, AsymmetricSignatureFormatter asymmetricSignatureFormatter)
 {
     if (InformationLoggingEnabled)
     {
         string data = string.Format(CultureInfo.InvariantCulture, SecurityResources.GetResourceString("Log_SigningAsymmetric"), new object[] { GetKeyName(key), signatureDescription.GetType().Name, hash.GetType().Name, asymmetricSignatureFormatter.GetType().Name });
         WriteLine(signedXml, TraceEventType.Information, SignedXmlDebugEvent.Signing, data);
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:SignedXmlDebugLog.cs


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