Пример #1
0
 public void RIPEMD160_d(string testName, RIPEMD160 hash, byte[] input, byte[] result)
 {
     hash.TransformFinalBlock(input, 0, input.Length);
     AssertEquals(testName + ".d", result, hash.Hash);
     // required or next operation will still return old hash
     hash.Initialize();
 }
Пример #2
0
 public void RIPEMD160_b(string testName, RIPEMD160 hash, byte[] input, byte[] result)
 {
     byte[] output = hash.ComputeHash(input, 0, input.Length);
     AssertEquals(testName + ".b.1", result, output);
     AssertEquals(testName + ".b.2", result, hash.Hash);
     // required or next operation will still return old hash
     hash.Initialize();
 }
Пример #3
0
        public void RIPEMD160_c(string testName, RIPEMD160 hash, byte[] input, byte[] result)
        {
            MemoryStream ms = new MemoryStream(input);

            byte[] output = hash.ComputeHash(ms);
            AssertEquals(testName + ".c.1", result, output);
            AssertEquals(testName + ".c.2", result, hash.Hash);
            // required or next operation will still return old hash
            hash.Initialize();
        }
Пример #4
0
        /// <summary>
        /// Spočítá MD160 hashi ze vstupního řetězce
        /// </summary>
        /// <param name="In">Vstupní řetězec</param>
        /// <returns>MD160 hashe v hexadecimální notaci</returns>
        private string RIPEMD160Hash(string In)
        {
            using (RIPEMD160 Hash = RIPEMD160.Create())
            {
                Hash.Initialize();
                byte[] OutHash = Hash.ComputeHash(Encoding.ASCII.GetBytes(In));

                return(ConvertHexToString(OutHash));
            }
        }
Пример #5
0
 public void RIPEMD160_e(string testName, RIPEMD160 hash, byte[] input, byte[] result)
 {
     byte[] copy = new byte [input.Length];
     for (int i = 0; i < input.Length - 1; i++)
     {
         hash.TransformBlock(input, i, 1, copy, i);
     }
     hash.TransformFinalBlock(input, input.Length - 1, 1);
     AssertEquals(testName + ".e", result, hash.Hash);
     // required or next operation will still return old hash
     hash.Initialize();
 }