Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Illegal base64 data at input byte 68

Tags:

base64

go

decode

I am getting: error: illegal base64 data at input byte 68 When passing in base64_edcode string into base64.StdEncoding.DecodeString(str):

the string is:

TbHl6ijhdKwXklzOkw5+/r5Yac0kED8Iyp/7suphsFLHSJAUGM8vZHeroTeJ9eF4PePO5A

but put the string into php base64_decoed is ok result is 0000000000bd583f958a7018c9[11,"string",8641231,1111]

Why?

like image 745
donglei Avatar asked Dec 18 '25 10:12

donglei


1 Answers

Because it's not a valid Base 64 string. It's missing the end padding. With proper padding:

TbHl6ijhdKwXklzOkw5+/r5Yac0kED8Iyp/7suphsFLHSJAUGM8vZHeroTeJ9eF4PePO5A==

it works, or you can tell the decoder not to look for padding:

    out, err := base64.StdEncoding.WithPadding(base64.NoPadding).DecodeString(str)
like image 153
Flimzy Avatar answered Dec 20 '25 03:12

Flimzy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!