From 5a6c3225245034a0d6d57b504abd2ba7f4a39d3c Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Wed, 17 Jan 2024 11:25:45 -0500 Subject: [PATCH] feat: add MultihashFromBytes --- encoding/multihash.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/encoding/multihash.go b/encoding/multihash.go index 6e2361d..33284ca 100644 --- a/encoding/multihash.go +++ b/encoding/multihash.go @@ -41,6 +41,10 @@ func (m *Multihash) HashBytes() []byte { return m.fullBytes[1:] } +func MultihashFromBytes(bytes []byte, kind types.HashType) *Multihash { + return NewMultihash(append([]byte{byte(kind)}, bytes...)) +} + func MultihashFromBase64Url(hash string) (*Multihash, error) { encoder, _ := multibase.EncoderByName("base64url") encoding, err := getEncoding(hash)