@@ -16,6 +16,10 @@ public static class HashTool
16
16
/// Get CRC-32, MD5, and SHA-1 hashes from an input file path
17
17
/// </summary>
18
18
/// <param name="filename">Path to the input file</param>
19
+ /// <param name="size">Calculated file size on success, -1 on error</param>
20
+ /// <param name="crc32">CRC-32 for the input file</param>
21
+ /// <param name="md5">MD5 for the input file</param>
22
+ /// <param name="sha1">SHA-1 for the input file</param>
19
23
/// <returns>True if hashing was successful, false otherwise</returns>
20
24
public static bool GetStandardHashes ( string filename , out long size , out string ? crc32 , out string ? md5 , out string ? sha1 )
21
25
{
@@ -39,6 +43,10 @@ public static bool GetStandardHashes(string filename, out long size, out string?
39
43
/// Get CRC-32, MD5, and SHA-1 hashes from an input stream
40
44
/// </summary>
41
45
/// <param name="stream">Input stream</param>
46
+ /// <param name="size">Calculated file size on success, -1 on error</param>
47
+ /// <param name="crc32">CRC-32 for the input file</param>
48
+ /// <param name="md5">MD5 for the input file</param>
49
+ /// <param name="sha1">SHA-1 for the input file</param>
42
50
/// <returns>True if hashing was successful, false otherwise</returns>
43
51
public static bool GetStandardHashes ( Stream stream , out long size , out string ? crc32 , out string ? md5 , out string ? sha1 )
44
52
{
@@ -120,6 +128,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
120
128
/// Get hashes and size from an input file path
121
129
/// </summary>
122
130
/// <param name="filename">Path to the input file</param>
131
+ /// <param name="size">Amount of bytes read during hashing</param>
123
132
/// <returns>Dictionary containing hashes on success, null on error</returns>
124
133
public static Dictionary < HashType , string ? > ? GetFileHashesAndSize ( string filename , out long size )
125
134
{
@@ -134,6 +143,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
134
143
/// Get hashes and size from an input file path
135
144
/// </summary>
136
145
/// <param name="filename">Path to the input file</param>
146
+ /// <param name="size">Amount of bytes read during hashing</param>
137
147
/// <returns>Dictionary containing hashes on success, null on error</returns>
138
148
public static Dictionary < HashType , byte [ ] ? > ? GetFileHashArraysAndSize ( string filename , out long size )
139
149
{
@@ -149,6 +159,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
149
159
/// </summary>
150
160
/// <param name="filename">Path to the input file</param>
151
161
/// <param name="hashType">Hash type to get from the file</param>
162
+ /// <param name="size">Amount of bytes read during hashing</param>
152
163
/// <returns>Hash and size on success, null on error</returns>
153
164
public static string ? GetFileHashAndSize ( string filename , HashType hashType , out long size )
154
165
{
@@ -161,6 +172,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
161
172
/// </summary>
162
173
/// <param name="filename">Path to the input file</param>
163
174
/// <param name="hashType">Hash type to get from the file</param>
175
+ /// <param name="size">Amount of bytes read during hashing</param>
164
176
/// <returns>Hash and size on success, null on error</returns>
165
177
public static byte [ ] ? GetFileHashArrayAndSize ( string filename , HashType hashType , out long size )
166
178
{
@@ -173,6 +185,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
173
185
/// </summary>
174
186
/// <param name="filename">Path to the input file</param>
175
187
/// <param name="hashTypes">Array of hash types to get from the file</param>
188
+ /// <param name="size">Amount of bytes read during hashing</param>
176
189
/// <returns>Dictionary containing hashes on success, null on error</returns>
177
190
public static Dictionary < HashType , string ? > ? GetFileHashesAndSize ( string filename , HashType [ ] hashTypes , out long size )
178
191
{
@@ -195,6 +208,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
195
208
/// </summary>
196
209
/// <param name="filename">Path to the input file</param>
197
210
/// <param name="hashTypes">Array of hash types to get from the file</param>
211
+ /// <param name="size">Amount of bytes read during hashing</param>
198
212
/// <returns>Dictionary containing hashes on success, null on error</returns>
199
213
public static Dictionary < HashType , byte [ ] ? > ? GetFileHashArraysAndSize ( string filename , HashType [ ] hashTypes , out long size )
200
214
{
@@ -294,6 +308,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
294
308
/// Get hashes from an input Stream
295
309
/// </summary>
296
310
/// <param name="input">Stream to hash</param>
311
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
297
312
/// <returns>Dictionary containing hashes on success, null on error</returns>
298
313
public static Dictionary < HashType , string ? > ? GetStreamHashes ( Stream input , bool leaveOpen = false )
299
314
=> GetStreamHashesAndSize ( input , leaveOpen , out _ ) ;
@@ -302,6 +317,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
302
317
/// Get hashes from an input Stream
303
318
/// </summary>
304
319
/// <param name="input">Stream to hash</param>
320
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
305
321
/// <returns>Dictionary containing hashes on success, null on error</returns>
306
322
public static Dictionary < HashType , byte [ ] ? > ? GetStreamHashArrays ( Stream input , bool leaveOpen = false )
307
323
=> GetStreamHashArraysAndSize ( input , leaveOpen , out _ ) ;
@@ -311,6 +327,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
311
327
/// </summary>
312
328
/// <param name="input">Stream to hash</param>
313
329
/// <param name="hashType">Hash type to get from the file</param>
330
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
314
331
/// <returns>Hash on success, null on error</returns>
315
332
public static string ? GetStreamHash ( Stream input , HashType hashType , bool leaveOpen = false )
316
333
=> GetStreamHashAndSize ( input , hashType , leaveOpen , out _ ) ;
@@ -320,6 +337,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
320
337
/// </summary>
321
338
/// <param name="input">Stream to hash</param>
322
339
/// <param name="hashType">Hash type to get from the file</param>
340
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
323
341
/// <returns>Hash on success, null on error</returns>
324
342
public static byte [ ] ? GetStreamHashArray ( Stream input , HashType hashType , bool leaveOpen = false )
325
343
=> GetStreamHashArrayAndSize ( input , hashType , leaveOpen , out _ ) ;
@@ -329,6 +347,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
329
347
/// </summary>
330
348
/// <param name="input">Stream to hash</param>
331
349
/// <param name="hashTypes">Array of hash types to get from the file</param>
350
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
332
351
/// <returns>Dictionary containing hashes on success, null on error</returns>
333
352
public static Dictionary < HashType , string ? > ? GetStreamHashes ( Stream input , HashType [ ] hashTypes , bool leaveOpen = false )
334
353
=> GetStreamHashesAndSize ( input , hashTypes , leaveOpen , out _ ) ;
@@ -338,6 +357,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
338
357
/// </summary>
339
358
/// <param name="input">Stream to hash</param>
340
359
/// <param name="hashTypes">Array of hash types to get from the file</param>
360
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
341
361
/// <returns>Dictionary containing hashes on success, null on error</returns>
342
362
public static Dictionary < HashType , byte [ ] ? > ? GetStreamHashArrays ( Stream input , HashType [ ] hashTypes , bool leaveOpen = false )
343
363
=> GetStreamHashArraysAndSize ( input , hashTypes , leaveOpen , out _ ) ;
@@ -350,6 +370,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
350
370
/// Get hashes and size from an input Stream
351
371
/// </summary>
352
372
/// <param name="input">Stream to hash</param>
373
+ /// <param name="size">Amount of bytes read during hashing</param>
353
374
/// <returns>Dictionary containing hashes on success, null on error</returns>
354
375
public static Dictionary < HashType , string ? > ? GetStreamHashesAndSize ( Stream input , out long size )
355
376
=> GetStreamHashesAndSize ( input , leaveOpen : false , out size ) ;
@@ -358,6 +379,8 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
358
379
/// Get hashes and size from an input Stream
359
380
/// </summary>
360
381
/// <param name="input">Stream to hash</param>
382
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
383
+ /// <param name="size">Amount of bytes read during hashing</param>
361
384
/// <returns>Dictionary containing hashes on success, null on error</returns>
362
385
public static Dictionary < HashType , string ? > ? GetStreamHashesAndSize ( Stream input , bool leaveOpen , out long size )
363
386
{
@@ -372,6 +395,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
372
395
/// Get hashes and size from an input Stream
373
396
/// </summary>
374
397
/// <param name="input">Stream to hash</param>
398
+ /// <param name="size">Amount of bytes read during hashing</param>
375
399
/// <returns>Dictionary containing hashes on success, null on error</returns>
376
400
public static Dictionary < HashType , byte [ ] ? > ? GetStreamHashArraysAndSize ( Stream input , out long size )
377
401
=> GetStreamHashArraysAndSize ( input , leaveOpen : false , out size ) ;
@@ -380,6 +404,8 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
380
404
/// Get hashes and size from an input Stream
381
405
/// </summary>
382
406
/// <param name="input">Stream to hash</param>
407
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
408
+ /// <param name="size">Amount of bytes read during hashing</param>
383
409
/// <returns>Dictionary containing hashes on success, null on error</returns>
384
410
public static Dictionary < HashType , byte [ ] ? > ? GetStreamHashArraysAndSize ( Stream input , bool leaveOpen , out long size )
385
411
{
@@ -395,6 +421,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
395
421
/// </summary>
396
422
/// <param name="input">Stream to hash</param>
397
423
/// <param name="hashType">Hash type to get from the file</param>
424
+ /// <param name="size">Amount of bytes read during hashing</param>
398
425
/// <returns>Hash on success, null on error</returns>
399
426
public static string ? GetStreamHashAndSize ( Stream input , HashType hashType , out long size )
400
427
=> GetStreamHashAndSize ( input , hashType , leaveOpen : false , out size ) ;
@@ -404,6 +431,8 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
404
431
/// </summary>
405
432
/// <param name="input">Stream to hash</param>
406
433
/// <param name="hashType">Hash type to get from the file</param>
434
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
435
+ /// <param name="size">Amount of bytes read during hashing</param>
407
436
/// <returns>Hash on success, null on error</returns>
408
437
public static string ? GetStreamHashAndSize ( Stream input , HashType hashType , bool leaveOpen , out long size )
409
438
{
@@ -416,6 +445,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
416
445
/// </summary>
417
446
/// <param name="input">Stream to hash</param>
418
447
/// <param name="hashType">Hash type to get from the file</param>
448
+ /// <param name="size">Amount of bytes read during hashing</param>
419
449
/// <returns>Hash on success, null on error</returns>
420
450
public static byte [ ] ? GetStreamHashArrayAndSize ( Stream input , HashType hashType , out long size )
421
451
=> GetStreamHashArrayAndSize ( input , hashType , leaveOpen : false , out size ) ;
@@ -425,6 +455,8 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
425
455
/// </summary>
426
456
/// <param name="input">Stream to hash</param>
427
457
/// <param name="hashType">Hash type to get from the file</param>
458
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
459
+ /// <param name="size">Amount of bytes read during hashing</param>
428
460
/// <returns>Hash on success, null on error</returns>
429
461
public static byte [ ] ? GetStreamHashArrayAndSize ( Stream input , HashType hashType , bool leaveOpen , out long size )
430
462
{
@@ -437,6 +469,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
437
469
/// </summary>
438
470
/// <param name="input">Stream to hash</param>
439
471
/// <param name="hashTypes">Array of hash types to get from the file</param>
472
+ /// <param name="size">Amount of bytes read during hashing</param>
440
473
/// <returns>Dictionary containing hashes on success, null on error</returns>
441
474
public static Dictionary < HashType , string ? > ? GetStreamHashesAndSize ( Stream input , HashType [ ] hashTypes , out long size )
442
475
=> GetStreamHashesAndSize ( input , hashTypes , leaveOpen : false , out size ) ;
@@ -446,6 +479,8 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
446
479
/// </summary>
447
480
/// <param name="input">Stream to hash</param>
448
481
/// <param name="hashTypes">Array of hash types to get from the file</param>
482
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
483
+ /// <param name="size">Amount of bytes read during hashing</param>
449
484
/// <returns>Dictionary containing hashes on success, null on error</returns>
450
485
public static Dictionary < HashType , string ? > ? GetStreamHashesAndSize ( Stream input , HashType [ ] hashTypes , bool leaveOpen , out long size )
451
486
{
@@ -493,6 +528,7 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
493
528
/// </summary>
494
529
/// <param name="input">Stream to hash</param>
495
530
/// <param name="hashTypes">Array of hash types to get from the file</param>
531
+ /// <param name="size">Amount of bytes read during hashing</param>
496
532
/// <returns>Dictionary containing hashes on success, null on error</returns>
497
533
public static Dictionary < HashType , byte [ ] ? > ? GetStreamHashArraysAndSize ( Stream input , HashType [ ] hashTypes , out long size )
498
534
=> GetStreamHashArraysAndSize ( input , hashTypes , leaveOpen : false , out size ) ;
@@ -502,6 +538,8 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
502
538
/// </summary>
503
539
/// <param name="input">Stream to hash</param>
504
540
/// <param name="hashTypes">Array of hash types to get from the file</param>
541
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
542
+ /// <param name="size">Amount of bytes read during hashing</param>
505
543
/// <returns>Dictionary containing hashes on success, null on error</returns>
506
544
public static Dictionary < HashType , byte [ ] ? > ? GetStreamHashArraysAndSize ( Stream input , HashType [ ] hashTypes , bool leaveOpen , out long size )
507
545
{
@@ -545,11 +583,12 @@ public static bool GetStandardHashes(Stream stream, out long size, out string? c
545
583
}
546
584
547
585
/// <summary>
548
- /// Get hashes from an input stream
586
+ /// Get hashes and size from an input Stream
549
587
/// </summary>
550
- /// <param name="input"></param>
551
- /// <param name="hashTypes"></param>
552
- /// <param name="leaveOpen"></param>
588
+ /// <param name="input">Stream to hash</param>
589
+ /// <param name="hashTypes">Array of hash types to get from the file</param>
590
+ /// <param name="leaveOpen">Indicates if the source stream should be left open after hashing</param>
591
+ /// <param name="size">Amount of bytes read during hashing</param>
553
592
/// <returns></returns>
554
593
private static Dictionary < HashType , HashWrapper > ? GetStreamHashesInternal ( Stream input , HashType [ ] hashTypes , bool leaveOpen , out long size )
555
594
{
0 commit comments