public int Blake2() { int a = 0; if (TestType == Types.ShortSentence) { for (int i = 0; i < _sentences.GetLength(0); i++) { _blake2.ComputeHash(_sentences[i]); a++; } } if (TestType == Types.Word) { for (int i = 0; i < _words.GetLength(0); i++) { _blake2.ComputeHash(_words[i]); a++; } } if (TestType == Types.LongText) { _blake2.ComputeHash(_longText); } return(a); }
/// <summary> /// return hash /// </summary> /// <param name="data"></param> /// <returns></returns> public static byte[] CalculateHash(byte[] data) { Blake2BConfig config = new Blake2BConfig(); config.HashSizeInBits = 256; IBlake2B blake2B = Blake2BFactory.Instance.Create(config); return(blake2B.ComputeHash(data).Hash); }
/// <summary> /// use UTF8 encode data and calculate hash /// </summary> /// <param name="data"></param> /// <returns></returns> public static byte[] CalculateHash(string data) { Blake2BConfig config = new Blake2BConfig(); config.HashSizeInBits = 256; IBlake2B blake2B = Blake2BFactory.Instance.Create(config); byte[] bytes = Encoding.UTF8.GetBytes(data); return(blake2B.ComputeHash(bytes).Hash); }