Skip to content

Commit

Permalink
hashing tool keccak512
Browse files Browse the repository at this point in the history
  • Loading branch information
0xbcdev committed Apr 10, 2024
1 parent 1d33ce3 commit ba5bc48
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ devd convert decode_base64 [base64]
```bash
devd hash md5 [input]
devd hash keccak256 [input]
devd hash keccak512 [input]
```

### Debug tools
Expand Down
4 changes: 2 additions & 2 deletions cmd/hash/keccak256.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func GetKeccak256Command() *cobra.Command {
Args: cobra.ExactArgs(1),
Run: func(_ *cobra.Command, args []string) {
input := strings.Join(args, " ")
hash := crypto.Keccak256Hash([]byte(input))
fmt.Println(hex.EncodeToString(hash.Bytes()))
hash := crypto.Keccak256([]byte(input))
fmt.Println(hex.EncodeToString(hash))
},
}

Expand Down
24 changes: 24 additions & 0 deletions cmd/hash/keccak512.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package hash

import (
"encoding/hex"
"fmt"
"github.com/ethereum/go-ethereum/crypto"
"github.com/spf13/cobra"
"strings"
)

func GetKeccak512Command() *cobra.Command {
cmd := &cobra.Command{
Use: "keccak512 [input]",
Short: "keccak512 hashing input",
Args: cobra.ExactArgs(1),
Run: func(_ *cobra.Command, args []string) {
input := strings.Join(args, " ")
hash := crypto.Keccak512([]byte(input))
fmt.Println(hex.EncodeToString(hash))
},
}

return cmd
}
1 change: 1 addition & 0 deletions cmd/hash/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func Commands() *cobra.Command {
cmd.AddCommand(
GetMd5Command(),
GetKeccak256Command(),
GetKeccak512Command(),
)

return cmd
Expand Down

0 comments on commit ba5bc48

Please sign in to comment.