experimental-cli/project/encoders.go

22 lines
473 B
Go
Raw Normal View History

2020-09-10 12:33:41 +00:00
package main
import (
"encoding/base32"
)
var alphabet = "0123456789ABCDEFGHJKMNPQRSTVWXYZ"
var encoder = base32.NewEncoding(alphabet).WithPadding(base32.NoPadding)
// B32Encode does Crockford 32 encoding on a string.
func B32Encode(data []byte) string {
return encoder.EncodeToString(data)
}
2020-09-11 12:12:51 +00:00
func encodePeerMhash(pubKey []byte) string {
return PeerSigil + B32Encode(pubKey)
2020-09-11 12:12:51 +00:00
}
func encodeBlobMhash(sha256 []byte) string {
return BlobSigil + B32Encode(sha256[:])
}