@@ -54,10 +54,14 @@ v2024-08-24.2000-threaded;
5454v2024-11-01.1630-threaded;
5555 added thread flag "-t" to allow user to specity CPU threads, ex: -t 16 // fixed default to use max CPU threads
5656 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
5761*/
5862
5963func 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" )
6165}
6266
6367// help function
@@ -68,9 +72,10 @@ func helpFunc() {
6872 //"./hashgen -m bcrypt -cost 8 -w wordlist.txt\n" +
6973 "cat wordlist | ./hashgen -m md5 -hashplain\n " +
7074 //"\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 " +
7276 "\n If -w is not specified, defaults to stdin\n " +
7377 "If -o is not specified, defaults to stdout\n " +
78+ "If -t is not specified, defaults to max available CPU threads\n " +
7479 "\n Modes:\t \t Hashcat Mode Equivalent:\n " +
7580 //"\nargon2id (very slow!)\n" +
7681 "base64encode\n " +
@@ -311,15 +316,16 @@ func hashBytes(hashFunc string, data []byte) string {
311316 decodedBytes := make ([]byte , base64 .StdEncoding .DecodedLen (len (data )))
312317 n , err := base64 .StdEncoding .Decode (decodedBytes , data )
313318 if err != nil {
314- return "Invalid Base64 string"
319+ fmt .Fprintln (os .Stderr , "Invalid Base64 string" )
320+ return ""
315321 }
316322 return string (decodedBytes [:n ]) // convert the decoded bytes to a string
317323 case "plaintext" , "plain" , "99999" :
318324 return string (data ) // convert byte slice to string
319325 default :
320326 log .Printf ("--> Invalid hash function: %s <--\n " , hashFunc )
321327 helpFunc ()
322- os .Exit (0 )
328+ os .Exit (1 )
323329 return ""
324330 }
325331}
@@ -396,7 +402,7 @@ func startProc(hashFunc string, inputFile string, outputPath string, hashPlainOu
396402 break
397403 }
398404 if err != nil {
399- fmt .Println (os .Stderr , "Error reading chunk:" , err )
405+ fmt .Fprintln (os .Stderr , "Error reading chunk:" , err )
400406 return
401407 }
402408 // logic to split chunks properly
@@ -440,7 +446,7 @@ func startProc(hashFunc string, inputFile string, outputPath string, hashPlainOu
440446 if outputPath != "" {
441447 outFile , err := os .Create (outputPath )
442448 if err != nil {
443- fmt .Println (os .Stderr , "Error creating output file:" , err )
449+ fmt .Fprintln (os .Stderr , "Error creating output file:" , err )
444450 return
445451 }
446452 defer outFile .Close ()
@@ -489,7 +495,12 @@ func main() {
489495 os .Exit (0 )
490496 }
491497 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 ))
493504 os .Exit (0 )
494505 }
495506 if * help {
@@ -518,14 +529,4 @@ func main() {
518529 startProc (* hashFunc , * inputFile , * outputFile , * hashPlainOutput , numThreads )
519530}
520531
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-
531532// end code
0 commit comments