hash: simplify Sha256 implementations
Use sha256.Sum256() and drop duplicating Sum() completely.
This commit is contained in:
parent
5c5878968b
commit
80c3c9035a
2 changed files with 15 additions and 47 deletions
|
@ -9,11 +9,8 @@ import (
|
|||
|
||||
func TestSha256(t *testing.T) {
|
||||
input := []byte("hello")
|
||||
data, err := Sha256(input)
|
||||
data := Sha256(input)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
expected := "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
|
||||
actual := hex.EncodeToString(data.Bytes())
|
||||
|
||||
|
@ -22,14 +19,10 @@ func TestSha256(t *testing.T) {
|
|||
|
||||
func TestHashDoubleSha256(t *testing.T) {
|
||||
input := []byte("hello")
|
||||
data, err := DoubleSha256(input)
|
||||
data := DoubleSha256(input)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
firstSha, _ := Sha256(input)
|
||||
doubleSha, _ := Sha256(firstSha.Bytes())
|
||||
firstSha := Sha256(input)
|
||||
doubleSha := Sha256(firstSha.Bytes())
|
||||
expected := hex.EncodeToString(doubleSha.Bytes())
|
||||
|
||||
actual := hex.EncodeToString(data.Bytes())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue