示例#1
0
        /// <summary>
        /// Computes a Lyra2 hash and returns the resulting hash..
        /// </summary>
        /// <param name="lyra2">The <see cref="Lyra2"/> instance to use.</param>
        /// <param name="kLen">The output buffer length.</param>
        /// <param name="pwd">The password buffer.</param>
        /// <param name="salt">The salt buffer.</param>
        /// <param name="timeCost">The time cost parameter.</param>
        /// <param name="nRows">The number of rows in each block.</param>
        /// <param name="nCols">The number of columns in each block.</param>
        /// <returns>The Lyra2 hash.</returns>
        public static byte[] ComputeBytes(this Lyra2 lyra2, int kLen, byte[] pwd, byte[] salt, ulong timeCost, ulong nRows, ulong nCols)
        {
            var hash = new byte[kLen];

            lyra2.Calculate(hash, pwd, salt, timeCost, nRows, nCols);
            return(hash);
        }
示例#2
0
        public byte[] ComputeHash(byte[] input)
        {
            // IT HOLDS INT32 - so 4 bytes * 8 = 32 bytes
            UInt64 hashSizeInBytes = 32;

            byte[] hashA;
            byte[] hashB = new byte[hashSizeInBytes];
            var    blake = new Blake256();

            hashA = blake.ComputeBytes(input).GetBytes();
            Lyra2.Lyra2 lyra2 = new Lyra2.Lyra2();
            lyra2.Calculate(hashB, hashA, hashA, 8, 8, 8);

            return(hashB);
        }