76 StringBuilder Response =
new StringBuilder();
79 foreach (
byte b
in Data)
89 Response.Append(b.ToString(
"x2"));
92 return Response.ToString();
102 using (MemoryStream Bytes =
new MemoryStream())
109 for (i = 0; i < c; i++)
113 if (ch >=
'0' && ch <=
'9')
114 b2 = (byte)(ch -
'0');
115 else if (ch >=
'a' && ch <=
'f')
116 b2 = (byte)(ch -
'a' + 10);
117 else if (ch >=
'A' && ch <=
'F')
118 b2 = (byte)(ch -
'A' + 10);
119 else if (ch ==
' ' || ch == 160)
142 return Bytes.ToArray();
172 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
202 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
232 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
262 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
293 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
324 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
355 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
386 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
419 using (SHA1 SHA1 = SHA1.Create())
421 Result = SHA1.ComputeHash(Data);
436 using (SHA1 SHA1 = SHA1.Create())
438 Result = SHA1.ComputeHash(Data);
473 using (SHA256 SHA256 = SHA256.Create())
475 Result = SHA256.ComputeHash(Data);
490 using (SHA256 SHA256 = SHA256.Create())
492 Result = SHA256.ComputeHash(Data);
527 using (SHA384 SHA384 = SHA384.Create())
529 Result = SHA384.ComputeHash(Data);
544 using (SHA384 SHA384 = SHA384.Create())
546 Result = SHA384.ComputeHash(Data);
581 using (SHA512 SHA512 = SHA512.Create())
583 Result = SHA512.ComputeHash(Data);
598 using (SHA512 SHA512 = SHA512.Create())
600 Result = SHA512.ComputeHash(Data);
635 using (MD5 MD5 = MD5.Create())
637 Result = MD5.ComputeHash(Data);
652 using (MD5 MD5 = MD5.Create())
654 Result = MD5.ComputeHash(Data);
681 using (HMACSHA1 HMACSHA1 =
new HMACSHA1(Key))
683 Result = HMACSHA1.ComputeHash(Data);
710 using (HMACSHA1 HMACSHA1 =
new HMACSHA1(Key))
712 Result = HMACSHA1.ComputeHash(Data);
739 using (HMACSHA256 HMACSHA256 =
new HMACSHA256(Key))
741 Result = HMACSHA256.ComputeHash(Data);
768 using (HMACSHA256 HMACSHA256 =
new HMACSHA256(Key))
770 Result = HMACSHA256.ComputeHash(Data);
797 using (HMACSHA384 HMACSHA384 =
new HMACSHA384(Key))
799 Result = HMACSHA384.ComputeHash(Data);
826 using (HMACSHA384 HMACSHA384 =
new HMACSHA384(Key))
828 Result = HMACSHA384.ComputeHash(Data);
855 using (HMACSHA512 HMACSHA512 =
new HMACSHA512(Key))
857 Result = HMACSHA512.ComputeHash(Data);
884 using (HMACSHA512 HMACSHA512 =
new HMACSHA512(Key))
886 Result = HMACSHA512.ComputeHash(Data);
913 using (HMACMD5 HMACMD5 =
new HMACMD5(Key))
915 Result = HMACMD5.ComputeHash(Data);
942 using (HMACMD5 HMACMD5 =
new HMACMD5(Key))
944 Result = HMACMD5.ComputeHash(Data);
975 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
1004 throw new ArgumentException(
"Unrecognized hash function", nameof(Function));
Contains methods for simple hash calculations.
static string ComputeHMACMD5HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHMACSHA256Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
static byte[] ComputeHMACHash(HashFunction Function, byte[] Key, byte[] Data)
Computes a hash of a block of binary data.
static string ComputeSHA512HashString(byte[] Data)
Computes the SHA-512 hash of a block of binary data.
static string ComputeHMACSHA512HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
static string BinaryToString(byte[] Data, bool SpaceDelimiter)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
static byte[] ComputeSHA384Hash(Stream Data)
Computes the SHA-384 hash of a block of binary data.
static string ComputeSHA384HashString(byte[] Data)
Computes the SHA-384 hash of a block of binary data.
static string ComputeSHA512HashString(Stream Data)
Computes the SHA-512 hash of a block of binary data.
static string ComputeHashString(HashFunction Function, byte[] Data)
Computes a hash of a block of binary data.
static byte[] ComputeHMACSHA384Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
static byte[] ComputeSHA256Hash(Stream Data)
Computes the SHA-256 hash of a block of binary data.
static string ComputeHMACSHA384HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
static string ComputeHMACHashString(HashFunction Function, byte[] Key, Stream Data)
Computes a hash of a block of binary data.
static byte[] ComputeSHA384Hash(byte[] Data)
Computes the SHA-384 hash of a block of binary data.
static string ComputeHMACSHA256HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
static string ComputeHMACSHA384HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
static string ComputeHMACSHA512HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
static byte[] ComputeHMACHash(HashFunction Function, byte[] Key, Stream Data)
Computes a hash of a block of binary data.
static string ComputeHMACSHA1HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHMACSHA1Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHash(HashFunction Function, Stream Data)
Computes a hash of a block of binary data.
static string ComputeSHA384HashString(Stream Data)
Computes the SHA-384 hash of a block of binary data.
static byte[] ComputeSHA1Hash(byte[] Data)
Computes the SHA-1 hash of a block of binary data.
static string ComputeHMACSHA256HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
static string ComputeSHA256HashString(byte[] Data)
Computes the SHA-256 hash of a block of binary data.
static byte[] StringToBinary(string s)
Parses a hex string.
static string ComputeHMACSHA1HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeSHA512Hash(byte[] Data)
Computes the SHA-512 hash of a block of binary data.
static string ComputeHashString(HashFunction Function, Stream Data)
Computes a hash of a block of binary data.
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
static byte[] ComputeHMACMD5Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHMACSHA256Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
static byte[] ComputeMD5Hash(Stream Data)
Computes the MD5 hash of a block of binary data.
static byte[] ComputeHMACMD5Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHMACSHA1Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHMACSHA512Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
static byte[] ComputeSHA512Hash(Stream Data)
Computes the SHA-512 hash of a block of binary data.
static byte[] ComputeSHA1Hash(Stream Data)
Computes the SHA-1 hash of a block of binary data.
static string ComputeSHA1HashString(Stream Data)
Computes the SHA-1 hash of a block of binary data.
static HashFunctionStream GetHashFunctionStream(HashFunction Function)
Converts an enumeration value to a delegate to the corresponding hash function.
static string ComputeHMACHashString(HashFunction Function, byte[] Key, byte[] Data)
Computes a hash of a block of binary data.
static string ComputeMD5HashString(Stream Data)
Computes the MD5 hash of a block of binary data.
static string ComputeHMACMD5HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
static byte[] ComputeHMACSHA512Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
static HashFunctionArray GetHashFunctionArray(HashFunction Function)
Converts an enumeration value to a delegate to the corresponding hash function.
static byte[] ComputeSHA256Hash(byte[] Data)
Computes the SHA-256 hash of a block of binary data.
static string ComputeSHA1HashString(byte[] Data)
Computes the SHA-1 hash of a block of binary data.
static string ComputeSHA256HashString(Stream Data)
Computes the SHA-256 hash of a block of binary data.
static byte[] ComputeHMACSHA384Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
static byte[] ComputeMD5Hash(byte[] Data)
Computes the MD5 hash of a block of binary data.
static string ComputeMD5HashString(byte[] Data)
Computes the MD5 hash of a block of binary data.
static byte[] ComputeHash(HashFunction Function, byte[] Data)
Computes a hash of a block of binary data.
delegate byte[] HashFunctionStream(Stream Data)
Delegate to hash function.
delegate byte[] HashFunctionArray(byte[] Data)
Delegate to hash function.
HashFunction
Hash method enumeration.