/// <summary> /// Compute the hash as a byte[]. /// </summary> public static byte[] ComputeHash(this HashAlgorithmName hashAlgorithmName, byte[] data) { using (var provider = hashAlgorithmName.GetHashProvider()) { return(provider.ComputeHash(data)); } }
internal static byte[] GetSignatureValueHash(HashAlgorithmName hashAlgorithmName, NativeCms nativeCms) { var signatureValue = nativeCms.GetEncryptedDigest(); using (var signatureValueStream = new MemoryStream(signatureValue)) using (var hashAlgorithm = hashAlgorithmName.GetHashProvider()) { return(hashAlgorithm.ComputeHash(signatureValueStream, leaveStreamOpen: false)); } }
internal static byte[] GetSignatureValueHash(HashAlgorithmName hashAlgorithm, NativeCms nativeCms) { var signatureValue = nativeCms.GetEncryptedDigest(); var signatureValueStream = new MemoryStream(signatureValue); var signatureValueHashByteArray = hashAlgorithm .GetHashProvider() .ComputeHash(signatureValueStream, leaveStreamOpen: false); return(signatureValueHashByteArray); }
public override Task <byte[]> GetArchiveHashAsync(HashAlgorithmName hashAlgorithm, CancellationToken token) { token.ThrowIfCancellationRequested(); if (ZipReadStream == null) { throw new SignatureException(Strings.SignedPackageUnableToAccessSignature); } ZipReadStream.Seek(offset: 0, origin: SeekOrigin.Begin); var hash = hashAlgorithm.GetHashProvider().ComputeHash(ZipReadStream, leaveStreamOpen: true); return(Task.FromResult(hash)); }
public override Task <byte[]> GetArchiveHashAsync(HashAlgorithmName hashAlgorithmName, CancellationToken token) { token.ThrowIfCancellationRequested(); ThrowIfZipReadStreamIsNull(); ZipReadStream.Seek(offset: 0, origin: SeekOrigin.Begin); using (var hashAlgorithm = hashAlgorithmName.GetHashProvider()) { var hash = hashAlgorithm.ComputeHash(ZipReadStream, leaveStreamOpen: true); return(Task.FromResult(hash)); } }
public static HashAlgorithm GetHashAlgorithm(HashAlgorithmName hashAlgorithmName) { return(hashAlgorithmName.GetHashProvider()); }