Error while decoding base64 string

It shouldn’t work there either, it’s an invalid base64 encoded string, it’s the wrong length. It looks like it is missing a = at the end, so it should be:

Base.decode64("eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhenAiOiI4NDgwMzc1NTA1Mi0zYjFpNXV2b2JubnRzOWw5MzJwaGdiMmE4dWRmaHRrbi5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImF1ZCI6Ijg0ODAzNzU1MDUyLTNiMWk1dXZvYm5udHM5bDkzMnBoZ2IyYTh1ZGZodGtuLmFwcHMuZ29vZ2xldXNlcmNvbnRlbnQuY29tIiwic3ViIjoiMTA4MDQ0Mjc2NDQ2NzkyNDUwODk0IiwiaGQiOiJhdmlhYmlyZC5jb20iLCJlbWFpbCI6ImFuc2h1bEBhdmlhYmlyZC5jb20iLCJlbWFpbF92ZXJpZmllZCI6dHJ1ZSwiYXRfaGFzaCI6ImlabDJ0S2JZZngwNjVtVGpQcEowT0EiLCJpYXQiOjE1NTkxNTQyNDQsImV4cCI6MTU1OTE1Nzg0NH0=")

So that website is probably just padding invalid base64 strings.

For note, you can add padding: false to Elixir’s Base.decode64/2 call to do the same automatically.

8 Likes