mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-02 13:03:11 +00:00
fix the padding
This commit is contained in:
parent
42839924e7
commit
ebd6de6a8b
@ -262,11 +262,18 @@ func garlic32StB(s string) ([]byte, error) {
|
||||
}
|
||||
}
|
||||
//compute the length to pad the address to, usually 56 or 64
|
||||
x := int((len(s)/8)+1) * 8
|
||||
for len(s) < x {
|
||||
s += "="
|
||||
padout := func(s string) string {
|
||||
if len(s)%8 == 0 {
|
||||
return s
|
||||
}
|
||||
x := int((len(s)/8)+1) * 8
|
||||
for len(s) < x {
|
||||
s += "="
|
||||
}
|
||||
return s
|
||||
}
|
||||
garlicHostBytes, err := garlicBase32Encoding.DecodeString(s[0:56])
|
||||
|
||||
garlicHostBytes, err := garlicBase32Encoding.DecodeString(padout(s))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to decode base32 garlic addr: %s, err: %v len: %v", s, err, len(s))
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user