mirror of
https://github.com/logos-messaging/go-multiaddr.git
synced 2026-01-02 13:03:11 +00:00
fix how the padding is computed
This commit is contained in:
parent
946a6f66c0
commit
ae5c4f834c
@ -261,18 +261,14 @@ func garlic32StB(s string) ([]byte, error) {
|
||||
return nil, fmt.Errorf("failed to parse garlic addr: %s not a i2p base32 address. len: %d", s, len(s))
|
||||
}
|
||||
}
|
||||
|
||||
for len(s) < 56 {
|
||||
//compute the length to pad the address to, usually 56 or 64
|
||||
x := int((len(s)/8)+1) * 8
|
||||
for len(s) < x {
|
||||
s += "="
|
||||
}
|
||||
|
||||
garlicHostBytes, err := garlicBase32Encoding.DecodeString(s)
|
||||
garlicHostBytes, err := garlicBase32Encoding.DecodeString(s[0:56])
|
||||
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))
|
||||
}
|
||||
return garlicHostBytes, nil
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user