@@ -15,6 +15,7 @@ import (
1515
1616 "github.com/TimothyStiles/poly"
1717 "github.com/urfave/cli/v2"
18+ "lukechampine.com/blake3"
1819)
1920
2021/******************************************************************************
@@ -188,8 +189,8 @@ func hashCommand(c *cli.Context) error {
188189
189190 // handler for outputting JSON to stdout
190191 if c .String ("o" ) == "json" {
191- annotatedSequence .Sequence .Hash = sequenceHash // adding hash to JSON
192- annotatedSequence .Sequence .HashFunction = strings .ToUpper (c .String ("f" )) // adding hash type to JSON
192+ annotatedSequence .Sequence .SequenceHash = sequenceHash // adding hash to JSON
193+ annotatedSequence .Sequence .SequenceHashFunction = strings .ToUpper (c .String ("f" )) // adding hash type to JSON
193194 output , _ := json .MarshalIndent (annotatedSequence , "" , " " )
194195 fmt .Fprint (c .App .Writer , string (output ))
195196 }
@@ -240,8 +241,8 @@ func hashCommand(c *cli.Context) error {
240241
241242 // handler for outputting JSON.
242243 if strings .ToLower (c .String ("o" )) == "json" {
243- annotatedSequence .Sequence .Hash = sequenceHash
244- annotatedSequence .Sequence .HashFunction = strings .ToUpper (c .String ("f" ))
244+ annotatedSequence .Sequence .SequenceHash = sequenceHash
245+ annotatedSequence .Sequence .SequenceHashFunction = strings .ToUpper (c .String ("f" ))
245246
246247 if c .Bool ("--log" ) == true {
247248 output , _ := json .MarshalIndent (annotatedSequence , "" , " " )
@@ -436,45 +437,46 @@ func flagSwitchHash(c *cli.Context, annotatedSequence poly.AnnotatedSequence) st
436437 var hashString string
437438 switch strings .ToUpper (c .String ("f" )) {
438439 case "MD5" :
439- hashString = annotatedSequence .Hash (crypto .MD5 )
440+ hashString = annotatedSequence .Hash (crypto .MD5 . New () )
440441 case "SHA1" :
441- hashString = annotatedSequence .Hash (crypto .SHA1 )
442+ hashString = annotatedSequence .Hash (crypto .SHA1 . New () )
442443 case "SHA244" :
443- hashString = annotatedSequence .Hash (crypto .SHA224 )
444+ hashString = annotatedSequence .Hash (crypto .SHA224 . New () )
444445 case "SHA256" :
445- hashString = annotatedSequence .Hash (crypto .SHA256 )
446+ hashString = annotatedSequence .Hash (crypto .SHA256 . New () )
446447 case "SHA384" :
447- hashString = annotatedSequence .Hash (crypto .SHA384 )
448+ hashString = annotatedSequence .Hash (crypto .SHA384 . New () )
448449 case "SHA512" :
449- hashString = annotatedSequence .Hash (crypto .SHA512 )
450+ hashString = annotatedSequence .Hash (crypto .SHA512 . New () )
450451 case "RIPEMD160" :
451- hashString = annotatedSequence .Hash (crypto .RIPEMD160 )
452+ hashString = annotatedSequence .Hash (crypto .RIPEMD160 . New () )
452453 case "SHA3_224" :
453- hashString = annotatedSequence .Hash (crypto .SHA3_224 )
454+ hashString = annotatedSequence .Hash (crypto .SHA3_224 . New () )
454455 case "SHA3_256" :
455- hashString = annotatedSequence .Hash (crypto .SHA3_256 )
456+ hashString = annotatedSequence .Hash (crypto .SHA3_256 . New () )
456457 case "SHA3_384" :
457- hashString = annotatedSequence .Hash (crypto .SHA3_384 )
458+ hashString = annotatedSequence .Hash (crypto .SHA3_384 . New () )
458459 case "SHA3_512" :
459- hashString = annotatedSequence .Hash (crypto .SHA3_512 )
460+ hashString = annotatedSequence .Hash (crypto .SHA3_512 . New () )
460461 case "SHA512_224" :
461- hashString = annotatedSequence .Hash (crypto .SHA512_224 )
462+ hashString = annotatedSequence .Hash (crypto .SHA512_224 . New () )
462463 case "SHA512_256" :
463- hashString = annotatedSequence .Hash (crypto .SHA512_256 )
464+ hashString = annotatedSequence .Hash (crypto .SHA512_256 . New () )
464465 case "BLAKE2s_256" :
465- hashString = annotatedSequence .Hash (crypto .BLAKE2s_256 )
466+ hashString = annotatedSequence .Hash (crypto .BLAKE2s_256 . New () )
466467 case "BLAKE2b_256" :
467- hashString = annotatedSequence .Hash (crypto .BLAKE2b_256 )
468+ hashString = annotatedSequence .Hash (crypto .BLAKE2b_256 . New () )
468469 case "BLAKE2b_384" :
469- hashString = annotatedSequence .Hash (crypto .BLAKE2b_384 )
470+ hashString = annotatedSequence .Hash (crypto .BLAKE2b_384 . New () )
470471 case "BLAKE2b_512" :
471- hashString = annotatedSequence .Hash (crypto .BLAKE2b_512 )
472+ hashString = annotatedSequence .Hash (crypto .BLAKE2b_512 . New () )
472473 case "BLAKE3" :
473- hashString = annotatedSequence .Blake3Hash ()
474+ hashString = annotatedSequence .Hash (blake3 .New (32 , nil ))
475+ // hashString = annotatedSequence.Blake3Hash()
474476 case "NO" :
475477 hashString = poly .RotateSequence (annotatedSequence .Sequence .Sequence )
476478 default :
477- hashString = annotatedSequence .Blake3Hash ( )
479+ hashString = annotatedSequence .Hash ( blake3 . New ( 32 , nil ) )
478480 break
479481 }
480482 return hashString
0 commit comments