/// <summary> /// Computes the FNV-1a 256-bit hash for the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns>The FNV-1a 256-bit hash of the specified data.</returns> // ReSharper disable once InconsistentNaming private static string Fnv1a256s(this string data) { using (HashAlgorithm alg = new Fnv1a256()) { string value = new BigInteger(alg.ComputeHash(UTF8.GetBytes(data)).AddZero()).ToString("X64", InvariantCulture); return("0x" + value.Substring(value.Length - 64)); } }
/// <summary> /// Asynchronously computes the FNV-1a 256-bit hash for the specified data. /// </summary> /// <param name="data">The data.</param> /// <returns>An asynchronous <see cref="Task{TResult}"/> containing the FNV-1a 256-bit hash of the specified data.</returns> // ReSharper disable once InconsistentNaming private static async Task <string> Fnv1a256sAsync(this string data) { using (HashAlgorithm alg = new Fnv1a256()) { string value = new BigInteger(alg.ComputeHash(UTF8.GetBytes(data)).AddZero()).ToString("X64", InvariantCulture); return(await Task.FromResult("0x" + value.Substring(value.Length - 64)).ConfigureAwait(false)); } }