Skip to content

Commit

Permalink
Add Blake2b256 and Blake2b512 hashing
Browse files Browse the repository at this point in the history
  • Loading branch information
autholykos committed May 26, 2020
1 parent b7d73ad commit a3275cd
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions hash/hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,31 @@ import (
"strconv"

"github.com/OneOfOne/xxhash"
"golang.org/x/crypto/blake2b"
"golang.org/x/crypto/sha3"
)

// Hash is a convenient alias of hash.Hash
type Hash = hash.Hash

// Blake2b256 performs a Blake2 hashing of a binary payload
func Blake2b256(bs []byte) ([]byte, error) {
h, err := blake2b.New256(nil)
if err != nil {
return nil, err
}
return PerformHash(h, bs)
}

// Blake2b512 performs a Blake2 hashing of a binary payload
func Blake2b512(bs []byte) ([]byte, error) {
h, err := blake2b.New512(nil)
if err != nil {
return nil, err
}
return PerformHash(h, bs)
}

// Sha3256 takes a byte slice
// and returns the SHA3-256 hash
func Sha3256(bs []byte) ([]byte, error) {
Expand Down

0 comments on commit a3275cd

Please sign in to comment.