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


C# IDigest.BlockUpdate方法代码示例

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


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

示例1: HashPaddedPair

 private static BigInteger HashPaddedPair(IDigest digest, BigInteger N, BigInteger n1, BigInteger n2)
 {
     int length = (N.BitLength + 7) / 8;
     byte[] padded = GetPadded(n1, length);
     byte[] input = GetPadded(n2, length);
     digest.BlockUpdate(padded, 0, padded.Length);
     digest.BlockUpdate(input, 0, input.Length);
     byte[] output = new byte[digest.GetDigestSize()];
     digest.DoFinal(output, 0);
     return new BigInteger(1, output).Mod(N);
 }
开发者ID:Novo,项目名称:apbprivateserver,代码行数:11,代码来源:Srp6Utilities.cs

示例2: CalculateX

 public static BigInteger CalculateX(IDigest digest, BigInteger N, byte[] salt, byte[] identity, byte[] password)
 {
     byte[] output = new byte[digest.GetDigestSize()];
     digest.BlockUpdate(identity, 0, identity.Length);
     digest.Update(0x3a);
     digest.BlockUpdate(password, 0, password.Length);
     digest.DoFinal(output, 0);
     digest.BlockUpdate(salt, 0, salt.Length);
     digest.BlockUpdate(output, 0, output.Length);
     digest.DoFinal(output, 0);
     return new BigInteger(1, output).Mod(N);
 }
开发者ID:Novo,项目名称:apbprivateserver,代码行数:12,代码来源:Srp6Utilities.cs

示例3: HashPaddedPair

        private static BigInteger HashPaddedPair(IDigest digest, BigInteger N, BigInteger n1, BigInteger n2)
        {
            int padLength = (N.BitLength + 7) / 8;

            byte[] n1_bytes = GetPadded(n1, padLength);
            byte[] n2_bytes = GetPadded(n2, padLength);

            digest.BlockUpdate(n1_bytes, 0, n1_bytes.Length);
            digest.BlockUpdate(n2_bytes, 0, n2_bytes.Length);

            byte[] output = new byte[digest.GetDigestSize()];
            digest.DoFinal(output, 0);

            return new BigInteger(1, output).Mod(N);
        }
开发者ID:Novo,项目名称:apbprivateserver,代码行数:15,代码来源:SRP6Utilities.cs

示例4: Encode

		/// <summary>
		/// Encode the stream with the given digest.
		/// </summary>
		/// <param name="data">The byte array to be encoded.</param>
		/// <param name="digest">The digest to be used.</param>
		/// <returns>Hashed value of the byte array as a hex string.</returns>
		private static string Encode(byte[] data, IDigest digest)
		{
			digest.BlockUpdate(data, 0, data.Length);
			byte[] output = new byte[digest.GetDigestSize()];
			digest.DoFinal (output, 0);
			return Hex.Encode(output);
		}
开发者ID:acschmit,项目名称:cryptography.Net,代码行数:13,代码来源:DigestSHA.cs

示例5: Compute

 public static byte[] Compute(IDigest hash, byte[] data)
 {
     var result = new byte[hash.GetDigestSize()];
     hash.BlockUpdate(data, 0, data.Length);
     hash.DoFinal(result, 0);
     return result;
 }
开发者ID:GridProtectionAlliance,项目名称:openHistorian,代码行数:7,代码来源:Hash.cs

示例6: GetHash

 private string GetHash(string s, IDigest algorithm)
 {
     var bytes = Encoding.UTF8.GetBytes(s);
     algorithm.BlockUpdate(bytes,0,bytes.Length);
     var res = new byte[algorithm.GetDigestSize()];
     algorithm.DoFinal(res, 0);
     return BitConverter.ToString(res).Replace("-", string.Empty);
 }
开发者ID:MediaFire,项目名称:mediafire-csharp-open-sdk,代码行数:8,代码来源:BouncyCastleCryptoService.cs

示例7: HashDF

	    /**
	     * Used by both Dual EC and Hash.
	     */
	    internal static byte[] HashDF(IDigest digest, byte[] seedMaterial, int seedLength)
	    {
	         // 1. temp = the Null string.
	        // 2. .
	        // 3. counter = an 8-bit binary value representing the integer "1".
	        // 4. For i = 1 to len do
	        // Comment : In step 4.1, no_of_bits_to_return
	        // is used as a 32-bit string.
	        // 4.1 temp = temp || Hash (counter || no_of_bits_to_return ||
	        // input_string).
	        // 4.2 counter = counter + 1.
	        // 5. requested_bits = Leftmost (no_of_bits_to_return) of temp.
	        // 6. Return SUCCESS and requested_bits.
	        byte[] temp = new byte[(seedLength + 7) / 8];

	        int len = temp.Length / digest.GetDigestSize();
	        int counter = 1;

	        byte[] dig = new byte[digest.GetDigestSize()];

	        for (int i = 0; i <= len; i++)
	        {
	            digest.Update((byte)counter);

	            digest.Update((byte)(seedLength >> 24));
	            digest.Update((byte)(seedLength >> 16));
	            digest.Update((byte)(seedLength >> 8));
	            digest.Update((byte)seedLength);

	            digest.BlockUpdate(seedMaterial, 0, seedMaterial.Length);

	            digest.DoFinal(dig, 0);

	            int bytesToCopy = ((temp.Length - i * dig.Length) > dig.Length)
	                    ? dig.Length
	                    : (temp.Length - i * dig.Length);
	            Array.Copy(dig, 0, temp, i * dig.Length, bytesToCopy);

	            counter++;
	        }

	        // do a left shift to get rid of excess bits.
	        if (seedLength % 8 != 0)
	        {
	            int shift = 8 - (seedLength % 8);
	            uint carry = 0;

                for (int i = 0; i != temp.Length; i++)
	            {
	                uint b = temp[i];
	                temp[i] = (byte)((b >> shift) | (carry << (8 - shift)));
	                carry = b;
	            }
	        }

            return temp;
	    }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:60,代码来源:DrbgUtilities.cs

示例8: Hash

        private static byte[] Hash(byte[] data, IDigest digestAlgoritm)
        {
            digestAlgoritm.BlockUpdate(data, 0, data.Length);

            var result = new byte[digestAlgoritm.GetDigestSize()];

            digestAlgoritm.DoFinal(result, 0);

            return result;
        }
开发者ID:endret,项目名称:hamustronclient,代码行数:10,代码来源:HashUtil.cs

示例9: MakeTestHash

		private byte[] MakeTestHash(
			IDigest digest)
		{
			for (int i = 0; i < digest.GetDigestSize(); ++i)
			{
				digest.Update((byte) i);
			}

			digest.BlockUpdate(TestBytes, 0, TestBytes.Length);

			return DigestUtilities.DoFinal(digest);
		}
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:12,代码来源:TestDigestUtil.cs

示例10: OaepEncoding

        public OaepEncoding(IAsymmetricBlockCipher cipher, IDigest hash, IDigest mgf1Hash, byte[] encodingParams)
        {
            _engine = cipher;
            _hash = hash;
            _mgf1Hash = mgf1Hash;
            _defHash = new byte[hash.GetDigestSize()];

            if (encodingParams != null)
            {
                hash.BlockUpdate(encodingParams, 0, encodingParams.Length);
            }

            hash.DoFinal(_defHash, 0);
        }
开发者ID:sanyaade-iot,项目名称:Schmoose-BouncyCastle,代码行数:14,代码来源:OaepEncoding.cs

示例11: UpdateDigestIncludingSize

 private static void UpdateDigestIncludingSize(IDigest digest, byte[] bytes)
 {
     digest.BlockUpdate(IntToByteArray(bytes.Length), 0, 4);
     digest.BlockUpdate(bytes, 0, bytes.Length);
     Arrays.Fill(bytes, (byte)0);
 }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:6,代码来源:JPakeUtilities.cs

示例12: UpdateDigest

 private static void UpdateDigest(IDigest digest, byte[] bytes)
 {
     digest.BlockUpdate(bytes, 0, bytes.Length);
     Arrays.Fill(bytes, (byte)0);
 }
开发者ID:KimikoMuffin,项目名称:bc-csharp,代码行数:5,代码来源:JPakeUtilities.cs

示例13: Digest

 public static byte[] Digest(IDigest d, byte[] b, int offset, int len) {
     d.BlockUpdate(b, offset, len);
     byte[] r = new byte[d.GetDigestSize()];
     d.DoFinal(r, 0);
     return r;
 }
开发者ID:Gianluigi,项目名称:dssnet,代码行数:6,代码来源:DigestAlgorithms.cs

示例14: SignEcDsa

		private byte[] SignEcDsa(IDigest digest, byte[] buffer, int length)
		{
			int digestSize = digest.GetDigestSize();

			ECDsaSigner signer = new ECDsaSigner();

			signer.Init(true, new ParametersWithRandom(PrivateKeyFactory.CreateKey(PrivateKey), _secureRandom));

			digest.BlockUpdate(buffer, 0, length);
			byte[] hash = new byte[digest.GetDigestSize()];
			digest.DoFinal(hash, 0);

			var signature = signer.GenerateSignature(hash);

			byte[] res = new byte[digestSize * 2];

			signature[0].ToByteArrayUnsigned().CopyTo(res, 0);
			signature[1].ToByteArrayUnsigned().CopyTo(res, digestSize);

			return res;
		}
开发者ID:huoxudong125,项目名称:ARSoft.Tools.Net,代码行数:21,代码来源:DnsKeyRecord.cs

示例15: DigestTest

        private void DigestTest(IDigest Digest, string[] Expected)
        {
            byte[] hash = new byte[Digest.DigestSize];

            for (int i = 0; i != _messages.Length; i++)
            {
                if (_messages.Length != 0)
                {
                    byte[] data = HexConverter.Decode(_messages[i]);
                    Digest.BlockUpdate(data, 0, data.Length);
                }

                Digest.DoFinal(hash, 0);

                if (Compare.AreEqual(HexConverter.Decode(Expected[i]), hash) == false)
                    throw new Exception("Keccak: Expected hash is not equal! Expected: " + Expected[i] + " Received: " + HexConverter.ToString(hash));
            }

            byte[] k64 = new byte[1024 * 64];

            for (int i = 0; i != k64.Length; i++)
                k64[i] = (byte)'a';

            Digest.BlockUpdate(k64, 0, k64.Length);
            Digest.DoFinal(hash, 0);

            if (Compare.AreEqual(HexConverter.Decode(Expected[_messages.Length]), hash) == false)
                throw new Exception("Keccak: Expected hash is not equal! Expected: " + Expected[_messages.Length] + " Received: " + HexConverter.ToString(hash));

            for (int i = 0; i != k64.Length; i++)
                Digest.Update((byte)'a');

            Digest.DoFinal(hash, 0);

            if (Compare.AreEqual(HexConverter.Decode(Expected[_messages.Length]), hash) == false)
                throw new Exception("Keccak: Expected hash is not equal! Expected: " + Expected[_messages.Length] + " Received: " + HexConverter.ToString(hash));

            for (int i = 0; i != k64.Length; i++)
                k64[i] = (byte)('a' + (i % 26));

            Digest.BlockUpdate(k64, 0, k64.Length);
            Digest.DoFinal(hash, 0);

            if (Compare.AreEqual(HexConverter.Decode(Expected[_messages.Length + 1]), hash) == false)
                throw new Exception("Keccak: Expected hash is not equal! Expected: " + Expected[_messages.Length + 1] + " Received: " + HexConverter.ToString(hash));

            for (int i = 0; i != 64; i++)
            {
                Digest.Update(k64[i * 1024]);
                Digest.BlockUpdate(k64, i * 1024 + 1, 1023);
            }

            Digest.DoFinal(hash, 0);

            if (Compare.AreEqual(HexConverter.Decode(Expected[_messages.Length + 1]), hash) == false)
                throw new Exception("Keccak: Expected hash is not equal! Expected: " + Expected[_messages.Length + 1] + " Received: " + HexConverter.ToString(hash));

            DoFinalTest(Digest);

            /*// very long test (passes)
            for (int i = 0; i != 16384; i++)
            {
                for (int j = 0; j != 1024; j++)
                    Digest.BlockUpdate(_xtremeData, 0, _xtremeData.Length);
            }

            Digest.DoFinal(hash, 0);

            if (Compare.AreEqual(HexConverter.Decode(Expected[_messages.Length + 2]), hash) == false)
                throw new Exception("Keccak: Expected hash is not equal! Expected: " + Expected[_messages.Length + 2] + " Received: " + hash);*/
        }
开发者ID:modulexcite,项目名称:CEX,代码行数:71,代码来源:KeccakTest.cs


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