Example #1
0
        public static bool TryHashData(ReadOnlySpan <byte> source, Span <byte> destination, HashAlgorithmName hashAlgorithm, out int bytesWritten)
        {
            // The classes that call us are sealed and their base class has checked this already.
            Debug.Assert(!string.IsNullOrEmpty(hashAlgorithm.Name));

            return
                (hashAlgorithm == HashAlgorithmName.SHA256 ? SHA256.TryHashData(source, destination, out bytesWritten) :
                 hashAlgorithm == HashAlgorithmName.SHA1 ? SHA1.TryHashData(source, destination, out bytesWritten) :
                 hashAlgorithm == HashAlgorithmName.SHA512 ? SHA512.TryHashData(source, destination, out bytesWritten) :
                 hashAlgorithm == HashAlgorithmName.SHA384 ? SHA384.TryHashData(source, destination, out bytesWritten) :
                 hashAlgorithm == HashAlgorithmName.MD5 ? MD5.TryHashData(source, destination, out bytesWritten) :
                 throw new CryptographicException(SR.Cryptography_UnknownHashAlgorithm, hashAlgorithm.Name));
        }
Example #2
0
 protected override bool TryHashData(ReadOnlySpan <byte> source, Span <byte> destination, out int bytesWritten)
 {
     return(SHA384.TryHashData(source, destination, out bytesWritten));
 }