I am getting:
error: illegal base64 data at input byte 2564
When I am decrypting two encoded strings:
data1:="8uxiowaHGmt6usI7U2SErXwpi/JLKbdhI3o...."(encrypted data)
data2:="iqqtWBCW7Ih9GAXubtIoLjucdIDfWd+oo2j...."(encrypted data)
data:=data1+data2
value, err = base64.StdEncoding.DecodeString(data)
if err != nil {
log.Println(err)
return
}
Can anyone suggest what could be the problem?
I ran into a somewhat similar issue; the solution for me was to use base64.RawStdEncoding, since my encoded string had already had its padding stripped.
Note: As the other answer mentions, if padding has not been stripped: you can not concatenate two base64encoded strings.
From the docs:
RawStdEncoding is the standard raw, unpadded base64 encoding, as defined in RFC 4648 section 3.2. This is the same as StdEncoding but omits padding characters.
var RawStdEncoding = StdEncoding.WithPadding(NoPadding)RawURLEncoding is the unpadded alternate base64 encoding defined in RFC 4648. It is typically used in URLs and file names. This is the same as URLEncoding but omits padding characters.
var RawURLEncoding = URLEncoding.WithPadding(NoPadding)StdEncoding is the standard base64 encoding, as defined in RFC 4648.
var StdEncoding = NewEncoding(encodeStd)URLEncoding is the alternate base64 encoding defined in RFC 4648. It is typically used in URLs and file names.
var URLEncoding = NewEncoding(encodeURL)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With