You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The base64 encoding (without padding): of 1 bytes gives 2 chars; of 2 bytes gives 3 chars. And the reverse mapping is true (2 chars decode to 1 byte; 3 chars to 2 bytes).
base64.RawURLEncoding.DecodedLen(2) returns 2, but should return 1.
base64.RawURLEncoding.DecodedLen(3) returns 3, but should return 2.
go version = 1.6
go env = windows, 386
http://play.golang.org/p/NzPTnjKUPy
The base64 encoding (without padding): of 1 bytes gives 2 chars; of 2 bytes gives 3 chars. And the reverse mapping is true (2 chars decode to 1 byte; 3 chars to 2 bytes).
base64.RawURLEncoding.DecodedLen(2) returns 2, but should return 1.
base64.RawURLEncoding.DecodedLen(3) returns 3, but should return 2.
The bug is the calculation for the NoPadding case in DecodedLen:
WRONG
return (n*6 + 7) / 8
RIGHT
return n*6 / 8
https://golang.org/src/encoding/base64/base64.go
The text was updated successfully, but these errors were encountered: