mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-05 22:43:10 +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
|
//compute the length to pad the address to, usually 56 or 64
|
||||||
x := int((len(s)/8)+1) * 8
|
padout := func(s string) string {
|
||||||
for len(s) < x {
|
if len(s)%8 == 0 {
|
||||||
s += "="
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to decode base32 garlic addr: %s, err: %v len: %v", s, err, len(s))
|
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