Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
Hashes.cs
1using System;
2using System.IO;
3using System.Text;
5
6namespace Waher.Security
7{
13 public delegate byte[] HashFunctionArray(byte[] Data);
14
20 public delegate byte[] HashFunctionStream(Stream Data);
21
25 public enum HashFunction
26 {
30 MD5,
31
35 SHA1,
36
40 SHA256,
41
45 SHA384,
46
50 SHA512
51 }
52
56 public static class Hashes
57 {
63 public static string BinaryToString(byte[] Data)
64 {
65 return BinaryToString(Data, false);
66 }
67
74 public static string BinaryToString(byte[] Data, bool SpaceDelimiter)
75 {
76 StringBuilder Response = new StringBuilder();
77 bool First = true;
78
79 foreach (byte b in Data)
80 {
81 if (SpaceDelimiter)
82 {
83 if (First)
84 First = false;
85 else
86 Response.Append(' ');
87 }
88
89 Response.Append(b.ToString("x2"));
90 }
91
92 return Response.ToString();
93 }
94
100 public static byte[] StringToBinary(string s)
101 {
102 using (MemoryStream Bytes = new MemoryStream())
103 {
104 int i, c = s.Length;
105 byte b = 0, b2;
106 bool First = true;
107 char ch;
108
109 for (i = 0; i < c; i++)
110 {
111 ch = s[i];
112
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)
120 continue;
121 else
122 return null;
123
124 if (First)
125 {
126 b = b2;
127 First = false;
128 }
129 else
130 {
131 b <<= 4;
132 b |= b2;
133
134 Bytes.WriteByte(b);
135 First = true;
136 }
137 }
138
139 if (!First)
140 return null;
141
142 return Bytes.ToArray();
143 }
144 }
145
152 public static string ComputeHashString(HashFunction Function, byte[] Data)
153 {
154 switch (Function)
155 {
156 case HashFunction.MD5:
157 return ComputeMD5HashString(Data);
158
159 case HashFunction.SHA1:
160 return ComputeSHA1HashString(Data);
161
162 case HashFunction.SHA256:
163 return ComputeSHA256HashString(Data);
164
165 case HashFunction.SHA384:
166 return ComputeSHA384HashString(Data);
167
168 case HashFunction.SHA512:
169 return ComputeSHA512HashString(Data);
170
171 default:
172 throw new ArgumentException("Unrecognized hash function", nameof(Function));
173 }
174 }
175
182 public static string ComputeHashString(HashFunction Function, Stream Data)
183 {
184 switch (Function)
185 {
186 case HashFunction.MD5:
187 return BinaryToString(ComputeMD5Hash(Data));
188
189 case HashFunction.SHA1:
190 return BinaryToString(ComputeSHA1Hash(Data));
191
192 case HashFunction.SHA256:
193 return BinaryToString(ComputeSHA256Hash(Data));
194
195 case HashFunction.SHA384:
196 return BinaryToString(ComputeSHA384Hash(Data));
197
198 case HashFunction.SHA512:
199 return BinaryToString(ComputeSHA512Hash(Data));
200
201 default:
202 throw new ArgumentException("Unrecognized hash function", nameof(Function));
203 }
204 }
205
212 public static byte[] ComputeHash(HashFunction Function, byte[] Data)
213 {
214 switch (Function)
215 {
216 case HashFunction.MD5:
217 return ComputeMD5Hash(Data);
218
219 case HashFunction.SHA1:
220 return ComputeSHA1Hash(Data);
221
222 case HashFunction.SHA256:
223 return ComputeSHA256Hash(Data);
224
225 case HashFunction.SHA384:
226 return ComputeSHA384Hash(Data);
227
228 case HashFunction.SHA512:
229 return ComputeSHA512Hash(Data);
230
231 default:
232 throw new ArgumentException("Unrecognized hash function", nameof(Function));
233 }
234 }
235
242 public static byte[] ComputeHash(HashFunction Function, Stream Data)
243 {
244 switch (Function)
245 {
246 case HashFunction.MD5:
247 return ComputeMD5Hash(Data);
248
249 case HashFunction.SHA1:
250 return ComputeSHA1Hash(Data);
251
252 case HashFunction.SHA256:
253 return ComputeSHA256Hash(Data);
254
255 case HashFunction.SHA384:
256 return ComputeSHA384Hash(Data);
257
258 case HashFunction.SHA512:
259 return ComputeSHA512Hash(Data);
260
261 default:
262 throw new ArgumentException("Unrecognized hash function", nameof(Function));
263 }
264 }
265
273 public static string ComputeHMACHashString(HashFunction Function, byte[] Key, byte[] Data)
274 {
275 switch (Function)
276 {
277 case HashFunction.MD5:
278 return ComputeHMACMD5HashString(Key, Data);
279
280 case HashFunction.SHA1:
281 return ComputeHMACSHA1HashString(Key, Data);
282
283 case HashFunction.SHA256:
284 return ComputeHMACSHA256HashString(Key, Data);
285
286 case HashFunction.SHA384:
287 return ComputeHMACSHA384HashString(Key, Data);
288
289 case HashFunction.SHA512:
290 return ComputeHMACSHA512HashString(Key, Data);
291
292 default:
293 throw new ArgumentException("Unrecognized hash function", nameof(Function));
294 }
295 }
296
304 public static string ComputeHMACHashString(HashFunction Function, byte[] Key, Stream Data)
305 {
306 switch (Function)
307 {
308 case HashFunction.MD5:
309 return BinaryToString(ComputeHMACMD5Hash(Key, Data));
310
311 case HashFunction.SHA1:
312 return BinaryToString(ComputeHMACSHA1Hash(Key, Data));
313
314 case HashFunction.SHA256:
315 return BinaryToString(ComputeHMACSHA256Hash(Key, Data));
316
317 case HashFunction.SHA384:
318 return BinaryToString(ComputeHMACSHA384Hash(Key, Data));
319
320 case HashFunction.SHA512:
321 return BinaryToString(ComputeHMACSHA512Hash(Key, Data));
322
323 default:
324 throw new ArgumentException("Unrecognized hash function", nameof(Function));
325 }
326 }
327
335 public static byte[] ComputeHMACHash(HashFunction Function, byte[] Key, byte[] Data)
336 {
337 switch (Function)
338 {
339 case HashFunction.MD5:
340 return ComputeHMACMD5Hash(Key, Data);
341
342 case HashFunction.SHA1:
343 return ComputeHMACSHA1Hash(Key, Data);
344
345 case HashFunction.SHA256:
346 return ComputeHMACSHA256Hash(Key, Data);
347
348 case HashFunction.SHA384:
349 return ComputeHMACSHA384Hash(Key, Data);
350
351 case HashFunction.SHA512:
352 return ComputeHMACSHA512Hash(Key, Data);
353
354 default:
355 throw new ArgumentException("Unrecognized hash function", nameof(Function));
356 }
357 }
358
366 public static byte[] ComputeHMACHash(HashFunction Function, byte[] Key, Stream Data)
367 {
368 switch (Function)
369 {
370 case HashFunction.MD5:
371 return ComputeHMACMD5Hash(Key, Data);
372
373 case HashFunction.SHA1:
374 return ComputeHMACSHA1Hash(Key, Data);
375
376 case HashFunction.SHA256:
377 return ComputeHMACSHA256Hash(Key, Data);
378
379 case HashFunction.SHA384:
380 return ComputeHMACSHA384Hash(Key, Data);
381
382 case HashFunction.SHA512:
383 return ComputeHMACSHA512Hash(Key, Data);
384
385 default:
386 throw new ArgumentException("Unrecognized hash function", nameof(Function));
387 }
388 }
389
395 public static string ComputeSHA1HashString(byte[] Data)
396 {
397 return BinaryToString(ComputeSHA1Hash(Data));
398 }
399
405 public static string ComputeSHA1HashString(Stream Data)
406 {
407 return BinaryToString(ComputeSHA1Hash(Data));
408 }
409
415 public static byte[] ComputeSHA1Hash(byte[] Data)
416 {
417 byte[] Result;
418
419 using (SHA1 SHA1 = SHA1.Create())
420 {
421 Result = SHA1.ComputeHash(Data);
422 }
423
424 return Result;
425 }
426
432 public static byte[] ComputeSHA1Hash(Stream Data)
433 {
434 byte[] Result;
435
436 using (SHA1 SHA1 = SHA1.Create())
437 {
438 Result = SHA1.ComputeHash(Data);
439 }
440
441 return Result;
442 }
443
449 public static string ComputeSHA256HashString(byte[] Data)
450 {
451 return BinaryToString(ComputeSHA256Hash(Data));
452 }
453
459 public static string ComputeSHA256HashString(Stream Data)
460 {
461 return BinaryToString(ComputeSHA256Hash(Data));
462 }
463
469 public static byte[] ComputeSHA256Hash(byte[] Data)
470 {
471 byte[] Result;
472
473 using (SHA256 SHA256 = SHA256.Create())
474 {
475 Result = SHA256.ComputeHash(Data);
476 }
477
478 return Result;
479 }
480
486 public static byte[] ComputeSHA256Hash(Stream Data)
487 {
488 byte[] Result;
489
490 using (SHA256 SHA256 = SHA256.Create())
491 {
492 Result = SHA256.ComputeHash(Data);
493 }
494
495 return Result;
496 }
497
503 public static string ComputeSHA384HashString(byte[] Data)
504 {
505 return BinaryToString(ComputeSHA384Hash(Data));
506 }
507
513 public static string ComputeSHA384HashString(Stream Data)
514 {
515 return BinaryToString(ComputeSHA384Hash(Data));
516 }
517
523 public static byte[] ComputeSHA384Hash(byte[] Data)
524 {
525 byte[] Result;
526
527 using (SHA384 SHA384 = SHA384.Create())
528 {
529 Result = SHA384.ComputeHash(Data);
530 }
531
532 return Result;
533 }
534
540 public static byte[] ComputeSHA384Hash(Stream Data)
541 {
542 byte[] Result;
543
544 using (SHA384 SHA384 = SHA384.Create())
545 {
546 Result = SHA384.ComputeHash(Data);
547 }
548
549 return Result;
550 }
551
557 public static string ComputeSHA512HashString(byte[] Data)
558 {
559 return BinaryToString(ComputeSHA512Hash(Data));
560 }
561
567 public static string ComputeSHA512HashString(Stream Data)
568 {
569 return BinaryToString(ComputeSHA512Hash(Data));
570 }
571
577 public static byte[] ComputeSHA512Hash(byte[] Data)
578 {
579 byte[] Result;
580
581 using (SHA512 SHA512 = SHA512.Create())
582 {
583 Result = SHA512.ComputeHash(Data);
584 }
585
586 return Result;
587 }
588
594 public static byte[] ComputeSHA512Hash(Stream Data)
595 {
596 byte[] Result;
597
598 using (SHA512 SHA512 = SHA512.Create())
599 {
600 Result = SHA512.ComputeHash(Data);
601 }
602
603 return Result;
604 }
605
611 public static string ComputeMD5HashString(byte[] Data)
612 {
613 return BinaryToString(ComputeMD5Hash(Data));
614 }
615
621 public static string ComputeMD5HashString(Stream Data)
622 {
623 return BinaryToString(ComputeMD5Hash(Data));
624 }
625
631 public static byte[] ComputeMD5Hash(byte[] Data)
632 {
633 byte[] Result;
634
635 using (MD5 MD5 = MD5.Create())
636 {
637 Result = MD5.ComputeHash(Data);
638 }
639
640 return Result;
641 }
642
648 public static byte[] ComputeMD5Hash(Stream Data)
649 {
650 byte[] Result;
651
652 using (MD5 MD5 = MD5.Create())
653 {
654 Result = MD5.ComputeHash(Data);
655 }
656
657 return Result;
658 }
659
666 public static string ComputeHMACSHA1HashString(byte[] Key, byte[] Data)
667 {
668 return BinaryToString(ComputeHMACSHA1Hash(Key, Data));
669 }
670
677 public static byte[] ComputeHMACSHA1Hash(byte[] Key, byte[] Data)
678 {
679 byte[] Result;
680
681 using (HMACSHA1 HMACSHA1 = new HMACSHA1(Key))
682 {
683 Result = HMACSHA1.ComputeHash(Data);
684 }
685
686 return Result;
687 }
688
695 public static string ComputeHMACSHA1HashString(byte[] Key, Stream Data)
696 {
697 return BinaryToString(ComputeHMACSHA1Hash(Key, Data));
698 }
699
706 public static byte[] ComputeHMACSHA1Hash(byte[] Key, Stream Data)
707 {
708 byte[] Result;
709
710 using (HMACSHA1 HMACSHA1 = new HMACSHA1(Key))
711 {
712 Result = HMACSHA1.ComputeHash(Data);
713 }
714
715 return Result;
716 }
717
724 public static string ComputeHMACSHA256HashString(byte[] Key, byte[] Data)
725 {
726 return BinaryToString(ComputeHMACSHA256Hash(Key, Data));
727 }
728
735 public static byte[] ComputeHMACSHA256Hash(byte[] Key, byte[] Data)
736 {
737 byte[] Result;
738
739 using (HMACSHA256 HMACSHA256 = new HMACSHA256(Key))
740 {
741 Result = HMACSHA256.ComputeHash(Data);
742 }
743
744 return Result;
745 }
746
753 public static string ComputeHMACSHA256HashString(byte[] Key, Stream Data)
754 {
755 return BinaryToString(ComputeHMACSHA256Hash(Key, Data));
756 }
757
764 public static byte[] ComputeHMACSHA256Hash(byte[] Key, Stream Data)
765 {
766 byte[] Result;
767
768 using (HMACSHA256 HMACSHA256 = new HMACSHA256(Key))
769 {
770 Result = HMACSHA256.ComputeHash(Data);
771 }
772
773 return Result;
774 }
775
782 public static string ComputeHMACSHA384HashString(byte[] Key, byte[] Data)
783 {
784 return BinaryToString(ComputeHMACSHA384Hash(Key, Data));
785 }
786
793 public static byte[] ComputeHMACSHA384Hash(byte[] Key, byte[] Data)
794 {
795 byte[] Result;
796
797 using (HMACSHA384 HMACSHA384 = new HMACSHA384(Key))
798 {
799 Result = HMACSHA384.ComputeHash(Data);
800 }
801
802 return Result;
803 }
804
811 public static string ComputeHMACSHA384HashString(byte[] Key, Stream Data)
812 {
813 return BinaryToString(ComputeHMACSHA384Hash(Key, Data));
814 }
815
822 public static byte[] ComputeHMACSHA384Hash(byte[] Key, Stream Data)
823 {
824 byte[] Result;
825
826 using (HMACSHA384 HMACSHA384 = new HMACSHA384(Key))
827 {
828 Result = HMACSHA384.ComputeHash(Data);
829 }
830
831 return Result;
832 }
833
840 public static string ComputeHMACSHA512HashString(byte[] Key, byte[] Data)
841 {
842 return BinaryToString(ComputeHMACSHA512Hash(Key, Data));
843 }
844
851 public static byte[] ComputeHMACSHA512Hash(byte[] Key, byte[] Data)
852 {
853 byte[] Result;
854
855 using (HMACSHA512 HMACSHA512 = new HMACSHA512(Key))
856 {
857 Result = HMACSHA512.ComputeHash(Data);
858 }
859
860 return Result;
861 }
862
869 public static string ComputeHMACSHA512HashString(byte[] Key, Stream Data)
870 {
871 return BinaryToString(ComputeHMACSHA512Hash(Key, Data));
872 }
873
880 public static byte[] ComputeHMACSHA512Hash(byte[] Key, Stream Data)
881 {
882 byte[] Result;
883
884 using (HMACSHA512 HMACSHA512 = new HMACSHA512(Key))
885 {
886 Result = HMACSHA512.ComputeHash(Data);
887 }
888
889 return Result;
890 }
891
898 public static string ComputeHMACMD5HashString(byte[] Key, byte[] Data)
899 {
900 return BinaryToString(ComputeHMACMD5Hash(Key, Data));
901 }
902
909 public static byte[] ComputeHMACMD5Hash(byte[] Key, byte[] Data)
910 {
911 byte[] Result;
912
913 using (HMACMD5 HMACMD5 = new HMACMD5(Key))
914 {
915 Result = HMACMD5.ComputeHash(Data);
916 }
917
918 return Result;
919 }
920
927 public static string ComputeHMACMD5HashString(byte[] Key, Stream Data)
928 {
929 return BinaryToString(ComputeHMACMD5Hash(Key, Data));
930 }
931
938 public static byte[] ComputeHMACMD5Hash(byte[] Key, Stream Data)
939 {
940 byte[] Result;
941
942 using (HMACMD5 HMACMD5 = new HMACMD5(Key))
943 {
944 Result = HMACMD5.ComputeHash(Data);
945 }
946
947 return Result;
948 }
949
956 {
957 switch (Function)
958 {
959 case HashFunction.MD5:
960 return ComputeMD5Hash;
961
962 case HashFunction.SHA1:
963 return ComputeSHA1Hash;
964
965 case HashFunction.SHA256:
966 return ComputeSHA256Hash;
967
968 case HashFunction.SHA384:
969 return ComputeSHA384Hash;
970
971 case HashFunction.SHA512:
972 return ComputeSHA512Hash;
973
974 default:
975 throw new ArgumentException("Unrecognized hash function", nameof(Function));
976 }
977 }
978
985 {
986 switch (Function)
987 {
988 case HashFunction.MD5:
989 return ComputeMD5Hash;
990
991 case HashFunction.SHA1:
992 return ComputeSHA1Hash;
993
994 case HashFunction.SHA256:
995 return ComputeSHA256Hash;
996
997 case HashFunction.SHA384:
998 return ComputeSHA384Hash;
999
1000 case HashFunction.SHA512:
1001 return ComputeSHA512Hash;
1002
1003 default:
1004 throw new ArgumentException("Unrecognized hash function", nameof(Function));
1005 }
1006 }
1007
1008 }
1009}
Contains methods for simple hash calculations.
Definition: Hashes.cs:57
static string ComputeHMACMD5HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:927
static byte[] ComputeHMACSHA256Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
Definition: Hashes.cs:764
static byte[] ComputeHMACHash(HashFunction Function, byte[] Key, byte[] Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:335
static string ComputeSHA512HashString(byte[] Data)
Computes the SHA-512 hash of a block of binary data.
Definition: Hashes.cs:557
static string ComputeHMACSHA512HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
Definition: Hashes.cs:840
static string BinaryToString(byte[] Data, bool SpaceDelimiter)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Definition: Hashes.cs:74
static byte[] ComputeSHA384Hash(Stream Data)
Computes the SHA-384 hash of a block of binary data.
Definition: Hashes.cs:540
static string ComputeSHA384HashString(byte[] Data)
Computes the SHA-384 hash of a block of binary data.
Definition: Hashes.cs:503
static string ComputeSHA512HashString(Stream Data)
Computes the SHA-512 hash of a block of binary data.
Definition: Hashes.cs:567
static string ComputeHashString(HashFunction Function, byte[] Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:152
static byte[] ComputeHMACSHA384Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
Definition: Hashes.cs:822
static byte[] ComputeSHA256Hash(Stream Data)
Computes the SHA-256 hash of a block of binary data.
Definition: Hashes.cs:486
static string ComputeHMACSHA384HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
Definition: Hashes.cs:782
static string ComputeHMACHashString(HashFunction Function, byte[] Key, Stream Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:304
static byte[] ComputeSHA384Hash(byte[] Data)
Computes the SHA-384 hash of a block of binary data.
Definition: Hashes.cs:523
static string ComputeHMACSHA256HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
Definition: Hashes.cs:724
static string ComputeHMACSHA384HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
Definition: Hashes.cs:811
static string ComputeHMACSHA512HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
Definition: Hashes.cs:869
static byte[] ComputeHMACHash(HashFunction Function, byte[] Key, Stream Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:366
static string ComputeHMACSHA1HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:666
static byte[] ComputeHMACSHA1Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:677
static byte[] ComputeHash(HashFunction Function, Stream Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:242
static string ComputeSHA384HashString(Stream Data)
Computes the SHA-384 hash of a block of binary data.
Definition: Hashes.cs:513
static byte[] ComputeSHA1Hash(byte[] Data)
Computes the SHA-1 hash of a block of binary data.
Definition: Hashes.cs:415
static string ComputeHMACSHA256HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
Definition: Hashes.cs:753
static string ComputeSHA256HashString(byte[] Data)
Computes the SHA-256 hash of a block of binary data.
Definition: Hashes.cs:449
static byte[] StringToBinary(string s)
Parses a hex string.
Definition: Hashes.cs:100
static string ComputeHMACSHA1HashString(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:695
static byte[] ComputeSHA512Hash(byte[] Data)
Computes the SHA-512 hash of a block of binary data.
Definition: Hashes.cs:577
static string ComputeHashString(HashFunction Function, Stream Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:182
static string BinaryToString(byte[] Data)
Converts an array of bytes to a string with their hexadecimal representations (in lower case).
Definition: Hashes.cs:63
static byte[] ComputeHMACMD5Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:909
static byte[] ComputeHMACSHA256Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-256 hash of a block of binary data.
Definition: Hashes.cs:735
static byte[] ComputeMD5Hash(Stream Data)
Computes the MD5 hash of a block of binary data.
Definition: Hashes.cs:648
static byte[] ComputeHMACMD5Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:938
static byte[] ComputeHMACSHA1Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:706
static byte[] ComputeHMACSHA512Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
Definition: Hashes.cs:851
static byte[] ComputeSHA512Hash(Stream Data)
Computes the SHA-512 hash of a block of binary data.
Definition: Hashes.cs:594
static byte[] ComputeSHA1Hash(Stream Data)
Computes the SHA-1 hash of a block of binary data.
Definition: Hashes.cs:432
static string ComputeSHA1HashString(Stream Data)
Computes the SHA-1 hash of a block of binary data.
Definition: Hashes.cs:405
static HashFunctionStream GetHashFunctionStream(HashFunction Function)
Converts an enumeration value to a delegate to the corresponding hash function.
Definition: Hashes.cs:984
static string ComputeHMACHashString(HashFunction Function, byte[] Key, byte[] Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:273
static string ComputeMD5HashString(Stream Data)
Computes the MD5 hash of a block of binary data.
Definition: Hashes.cs:621
static string ComputeHMACMD5HashString(byte[] Key, byte[] Data)
Computes the HMAC-SHA-1 hash of a block of binary data.
Definition: Hashes.cs:898
static byte[] ComputeHMACSHA512Hash(byte[] Key, Stream Data)
Computes the HMAC-SHA-512 hash of a block of binary data.
Definition: Hashes.cs:880
static HashFunctionArray GetHashFunctionArray(HashFunction Function)
Converts an enumeration value to a delegate to the corresponding hash function.
Definition: Hashes.cs:955
static byte[] ComputeSHA256Hash(byte[] Data)
Computes the SHA-256 hash of a block of binary data.
Definition: Hashes.cs:469
static string ComputeSHA1HashString(byte[] Data)
Computes the SHA-1 hash of a block of binary data.
Definition: Hashes.cs:395
static string ComputeSHA256HashString(Stream Data)
Computes the SHA-256 hash of a block of binary data.
Definition: Hashes.cs:459
static byte[] ComputeHMACSHA384Hash(byte[] Key, byte[] Data)
Computes the HMAC-SHA-384 hash of a block of binary data.
Definition: Hashes.cs:793
static byte[] ComputeMD5Hash(byte[] Data)
Computes the MD5 hash of a block of binary data.
Definition: Hashes.cs:631
static string ComputeMD5HashString(byte[] Data)
Computes the MD5 hash of a block of binary data.
Definition: Hashes.cs:611
static byte[] ComputeHash(HashFunction Function, byte[] Data)
Computes a hash of a block of binary data.
Definition: Hashes.cs:212
delegate byte[] HashFunctionStream(Stream Data)
Delegate to hash function.
delegate byte[] HashFunctionArray(byte[] Data)
Delegate to hash function.
HashFunction
Hash method enumeration.
Definition: Hashes.cs:26