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
|
|
|
|
2020-09-15 12:50:48 +00:00
|
|
|
func encodePeerMhash(pubKey []byte) string {
|
|
|
|
return PeerSigil + B32Encode(pubKey)
|
2020-09-11 12:12:51 +00:00
|
|
|
}
|
2020-09-29 00:34:16 +00:00
|
|
|
|
|
|
|
func encodeBlobMhash(sha256 [32]byte) string {
|
|
|
|
return BlobSigil + B32Encode(sha256[:])
|
|
|
|
}
|