public void SHA512_ByteAmount() { var sha = SHA512Value.ComputeFileSHA512(ThisFile); sha.GetBytes().Count.Should().Be(64); sha.ToString().Length.Should().Be(128); }
public void SHA512_ToString_and_Parse() { var sha = SHA512Value.ComputeFileSHA512(ThisFile); var s = sha.ToString(); var shaBis = SHA512Value.Parse(s); shaBis.Should().Be(sha); }
public async Task SHA512_from_file_async() { var sha = SHA512Value.ComputeFileSHA512(ThisFile); var sha2 = await SHA512Value.ComputeFileSHA512Async(ThisFile); sha2.Should().Be(sha); using (var compressedPath = new TemporaryFile()) { using (var input = new FileStream(ThisFile, FileMode.Open, FileAccess.Read, FileShare.Read, 4096, FileOptions.SequentialScan | FileOptions.Asynchronous)) using (var compressed = new FileStream(compressedPath.Path, FileMode.Truncate, FileAccess.Write, FileShare.None, 4096, FileOptions.SequentialScan | FileOptions.Asynchronous)) { var writer = GetCompressShellAsync(w => input.CopyToAsync(w)); await writer(compressed); } var shaCompressed = await SHA512Value.ComputeFileSHA512Async(compressedPath.Path); shaCompressed.Should().NotBe(sha); var localSha = await SHA512Value.ComputeFileSHA512Async(compressedPath.Path, r => new GZipStream(r, CompressionMode.Decompress, true)); localSha.Should().Be(sha); } }