예제 #1
0
파일: Encrypt.cs 프로젝트: Coflnet/cloud
        /// <summary>
        /// Hashes a given byte array with BLAKE2b (really fast).
        /// </summary>
        /// <returns>The hashed value as byte array</returns>
        /// <param name="message">Message to hash.</param>
        /// <param name="hashLength">Hash length (default 32).</param>
        public static byte[] Hash(byte[] message, int hashLength = 32)
        {
            int messageLength = message.Length;

            byte[] hash = new byte[hashLength];
            NativeLibsodium.crypto_generichash(hash, hashLength, message, messageLength, null, 0);
            return(hash);
        }