Skip to content

Commit ba5bc48

Browse files
committed
hashing tool keccak512
1 parent 1d33ce3 commit ba5bc48

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ devd convert decode_base64 [base64]
124124
```bash
125125
devd hash md5 [input]
126126
devd hash keccak256 [input]
127+
devd hash keccak512 [input]
127128
```
128129

129130
### Debug tools

cmd/hash/keccak256.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ func GetKeccak256Command() *cobra.Command {
1515
Args: cobra.ExactArgs(1),
1616
Run: func(_ *cobra.Command, args []string) {
1717
input := strings.Join(args, " ")
18-
hash := crypto.Keccak256Hash([]byte(input))
19-
fmt.Println(hex.EncodeToString(hash.Bytes()))
18+
hash := crypto.Keccak256([]byte(input))
19+
fmt.Println(hex.EncodeToString(hash))
2020
},
2121
}
2222

cmd/hash/keccak512.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package hash
2+
3+
import (
4+
"encoding/hex"
5+
"fmt"
6+
"github.com/ethereum/go-ethereum/crypto"
7+
"github.com/spf13/cobra"
8+
"strings"
9+
)
10+
11+
func GetKeccak512Command() *cobra.Command {
12+
cmd := &cobra.Command{
13+
Use: "keccak512 [input]",
14+
Short: "keccak512 hashing input",
15+
Args: cobra.ExactArgs(1),
16+
Run: func(_ *cobra.Command, args []string) {
17+
input := strings.Join(args, " ")
18+
hash := crypto.Keccak512([]byte(input))
19+
fmt.Println(hex.EncodeToString(hash))
20+
},
21+
}
22+
23+
return cmd
24+
}

cmd/hash/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ func Commands() *cobra.Command {
1414
cmd.AddCommand(
1515
GetMd5Command(),
1616
GetKeccak256Command(),
17+
GetKeccak512Command(),
1718
)
1819

1920
return cmd

0 commit comments

Comments
 (0)