Add HashFromBytes

This commit is contained in:
gagliardetto 2021-10-19 18:28:21 +02:00
parent b17c4ea14f
commit 07e95b99cd
2 changed files with 4 additions and 2 deletions

2
go.sum
View File

@ -89,8 +89,6 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/gagliardetto/binary v0.4.4 h1:EeADyw6t/5+/8Dtdt8LZ2X8Kd0vDJW0XXDi5iUgrFrc=
github.com/gagliardetto/binary v0.4.4/go.mod h1:peJR9PvwamL4YOh1nHWCPLry2VEfeeD1ADvewka7HnQ=
github.com/gagliardetto/binary v0.5.0 h1:fLVIbMEQp5zbW0SFtg0z/WHy2iUw/SMeuakzfa5ayhI=
github.com/gagliardetto/binary v0.5.0/go.mod h1:peJR9PvwamL4YOh1nHWCPLry2VEfeeD1ADvewka7HnQ=
github.com/gagliardetto/gofuzz v1.2.2 h1:XL/8qDMzcgvR4+CyRQW9UGdwPRPMHVJfqQ/uMvSUuQw=

View File

@ -43,6 +43,10 @@ func HashFromBase58(in string) (Hash, error) {
return Hash(tmp), nil
}
func HashFromBytes(in []byte) Hash {
return Hash(PublicKeyFromBytes(in))
}
func (ha Hash) MarshalJSON() ([]byte, error) {
return json.Marshal(base58.Encode(ha[:]))
}