@@ -54,10 +54,14 @@ v2024-08-24.2000-threaded;
54
54
v2024-11-01.1630-threaded;
55
55
added thread flag "-t" to allow user to specity CPU threads, ex: -t 16 // fixed default to use max CPU threads
56
56
added modes: sha2-224, sha2-384, sha2-512-224, sha2-512-256, keccak-256, keccak-512
57
+ v2024-11-04.1445-threaded;
58
+ fixed https://github.com/cyclone-github/hashgen/issues/5
59
+ added CPU threaded info to -help
60
+ cleaned up code and print functions
57
61
*/
58
62
59
63
func versionFunc () {
60
- fmt .Fprintln (os .Stderr , "Cyclone hash generator v2024-11-01.1630 -threaded" )
64
+ fmt .Fprintln (os .Stderr , "Cyclone hash generator v2024-11-04.1445 -threaded" )
61
65
}
62
66
63
67
// help function
@@ -68,9 +72,10 @@ func helpFunc() {
68
72
//"./hashgen -m bcrypt -cost 8 -w wordlist.txt\n" +
69
73
"cat wordlist | ./hashgen -m md5 -hashplain\n " +
70
74
//"\nSupported Options:\n-m {mode} -w {wordlist} -o {output_file} -hashplain {generates hash:plain pairs} -cost {bcrypt}\n" +
71
- "\n Supported Options:\n -m {mode} -w {wordlist} -o {output_file} -hashplain {generates hash:plain pairs}\n " +
75
+ "\n Supported Options:\n -m {mode} -w {wordlist} -t {cpu threads} - o {output_file} -hashplain {generates hash:plain pairs}\n " +
72
76
"\n If -w is not specified, defaults to stdin\n " +
73
77
"If -o is not specified, defaults to stdout\n " +
78
+ "If -t is not specified, defaults to max available CPU threads\n " +
74
79
"\n Modes:\t \t Hashcat Mode Equivalent:\n " +
75
80
//"\nargon2id (very slow!)\n" +
76
81
"base64encode\n " +
@@ -311,15 +316,16 @@ func hashBytes(hashFunc string, data []byte) string {
311
316
decodedBytes := make ([]byte , base64 .StdEncoding .DecodedLen (len (data )))
312
317
n , err := base64 .StdEncoding .Decode (decodedBytes , data )
313
318
if err != nil {
314
- return "Invalid Base64 string"
319
+ fmt .Fprintln (os .Stderr , "Invalid Base64 string" )
320
+ return ""
315
321
}
316
322
return string (decodedBytes [:n ]) // convert the decoded bytes to a string
317
323
case "plaintext" , "plain" , "99999" :
318
324
return string (data ) // convert byte slice to string
319
325
default :
320
326
log .Printf ("--> Invalid hash function: %s <--\n " , hashFunc )
321
327
helpFunc ()
322
- os .Exit (0 )
328
+ os .Exit (1 )
323
329
return ""
324
330
}
325
331
}
@@ -396,7 +402,7 @@ func startProc(hashFunc string, inputFile string, outputPath string, hashPlainOu
396
402
break
397
403
}
398
404
if err != nil {
399
- fmt .Println (os .Stderr , "Error reading chunk:" , err )
405
+ fmt .Fprintln (os .Stderr , "Error reading chunk:" , err )
400
406
return
401
407
}
402
408
// logic to split chunks properly
@@ -440,7 +446,7 @@ func startProc(hashFunc string, inputFile string, outputPath string, hashPlainOu
440
446
if outputPath != "" {
441
447
outFile , err := os .Create (outputPath )
442
448
if err != nil {
443
- fmt .Println (os .Stderr , "Error creating output file:" , err )
449
+ fmt .Fprintln (os .Stderr , "Error creating output file:" , err )
444
450
return
445
451
}
446
452
defer outFile .Close ()
@@ -489,7 +495,12 @@ func main() {
489
495
os .Exit (0 )
490
496
}
491
497
if * cyclone {
492
- funcBase64Decode ("Q29kZWQgYnkgY3ljbG9uZSA7KQo=" )
498
+ decodedStr , err := base64 .StdEncoding .DecodeString ("Q29kZWQgYnkgY3ljbG9uZSA7KQo=" )
499
+ if err != nil {
500
+ fmt .Fprintln (os .Stderr , "--> Cannot decode base64 string. <--" )
501
+ os .Exit (1 )
502
+ }
503
+ fmt .Fprintln (os .Stderr , string (decodedStr ))
493
504
os .Exit (0 )
494
505
}
495
506
if * help {
@@ -518,14 +529,4 @@ func main() {
518
529
startProc (* hashFunc , * inputFile , * outputFile , * hashPlainOutput , numThreads )
519
530
}
520
531
521
- // base64 decode function used for displaying encoded messages
522
- func funcBase64Decode (line string ) {
523
- str , err := base64 .StdEncoding .DecodeString (line )
524
- if err != nil {
525
- fmt .Fprintln (os .Stderr , "--> Text doesn't appear to be base64 encoded. <--" )
526
- os .Exit (0 )
527
- }
528
- fmt .Fprintf (os .Stderr , "%s\n " , str )
529
- }
530
-
531
532
// end code
0 commit comments