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


C# MD5CryptoServiceProvider.InternalHashCore方法代码示例

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


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

示例1: CryptDeriveKey

	// Derive a key for a specific cryptographic algorithm.
	public byte[] CryptDeriveKey(String algname, String alghashname,
								 int keySize, byte[] rgbIV)
			{
				if((algname == "DES" || algname == "RC2") &&
			   	   alghashname == "MD5" && keySize == 8)
				{
					// Use the older PKCS #5 password generation routine.
					MD5 md5 = new MD5CryptoServiceProvider();
					if(strPassword != null)
					{
						byte[] pwd = Encoding.UTF8.GetBytes(strPassword);
						md5.InternalHashCore(pwd, 0, pwd.Length);
						Array.Clear(pwd, 0, pwd.Length);
					}
					if(rgbSalt != null)
					{
						md5.InternalHashCore(rgbSalt, 0, rgbSalt.Length);
					}
					byte[] tempHash = md5.InternalHashFinal();
					md5.Initialize();
					int count = iterations;
					while(count > 1)
					{
						md5.InternalHashCore(tempHash, 0, tempHash.Length);
						Array.Clear(tempHash, 0, tempHash.Length);
						tempHash = md5.InternalHashFinal();
						md5.Initialize();
						--count;
					}
					byte[] key = new byte [8];
					Array.Copy(tempHash, 0, key, 0, 8);
					if(rgbIV != null)
					{
						Array.Copy(tempHash, 8, rgbIV, 0, 8);
					}
					Array.Clear(tempHash, 0, tempHash.Length);
					return key;
				}
				else
				{
					// Use the newer PKCS #5 password generation routine.
					Reset();
					if(alghashname != null)
					{
						strHashName = alghashname;
					}
					byte[] result = GetBytes(keySize);
					if(rgbIV != null)
					{
						byte[] iv = GetBytes(rgbIV.Length);
						Array.Copy(iv, 0, rgbIV, 0, rgbIV.Length);
						Array.Clear(iv, 0, iv.Length);
					}
					return result;
				}
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:57,代码来源:PasswordDeriveBytes.cs

示例2: Parse

	// Parse the contents of a certificate data block.
	private void Parse(byte[] data)
			{
				// Clone the data for internal storage.
				rawData = (byte[])(data.Clone());

				// Parse the ASN.1 data to get the field we are interested in.
				ASN1Parser parser = new ASN1Parser(rawData);
				ASN1Parser signed = parser.GetSequence();
				ASN1Parser certInfo = signed.GetSequence();
				if(certInfo.Type == ASN1Parser.ContextSpecific(0))
				{
					// Skip the version field.
					certInfo.Skip();
				}
				serialNumber = certInfo.GetContentsAsArray(ASN1Type.Integer);
				ASN1Parser algId = certInfo.GetSequence();
				issuer = ParseName(certInfo);
				ASN1Parser validity = certInfo.GetSequence();
				effectiveDate = validity.GetUTCTime();
				expirationDate = validity.GetUTCTime();
				name = ParseName(certInfo);
				ASN1Parser keyInfo = certInfo.GetSequence();
				algId = keyInfo.GetSequence();
				keyAlgorithm = ToHex(algId.GetObjectIdentifier());
				if(algId.IsAtEnd() || algId.IsNull())
				{
					keyAlgorithmParameters = null;
				}
				else
				{
					keyAlgorithmParameters = algId.GetWholeAsArray();
				}
				publicKey = keyInfo.GetBitString();

#if CONFIG_CRYPTO
				// Construct an MD5 hash of the certificate.  Is this correct?
				MD5 md5 = new MD5CryptoServiceProvider();
				md5.InternalHashCore(rawData, 0, rawData.Length);
				hash = md5.InternalHashFinal();
				md5.Initialize();
#endif
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:43,代码来源:X509Certificate.cs


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