Atob api question


I’m trying to decode some base64 strings on worker via atob() API. But it always throws DOMException with message atob() called with invalid base64-encoded data.

But it is actually a correct base64 encoded string and even has no non-ASCII characters in its origin data. It can be decoded correctly in my Chrome dev console atob() function. What should I do?

There are some example base64 strings that meet my problem:




1 Like

Interesting question.

Actually, from this url,

I can:

  1. Get a token leveraging the “GETTING THE API KEY” example;
  2. Using the generated token from the previous step, I can encrypt with success;
    3 But when trying to decrypt using a token obtained in the same manner, I get the same error reported originally in this post:

atob() called with invalid base64-encoded data. (Only whitespace, ‘+’, ‘/’, alphanumeric ASCII, and up to two terminal ‘=’ signs when the input data length is divisible by 4 are allowed.)

So, same problem here, no one to assist after the question being posted 8 months ago??

Well, this question is about the atob API in Workers.

This decodes fine.

return new Response(atob("NDIuMTU5Ljk0LjE1MTo1MDAwMDpvcmlnaW46cmM0LW1kNTpwbGFpbjpUbTlrWldaMWJtTjBhVzl1U0c5dVowdHZibWRDUzFobmEzQTJlbkpFYjNwU0lRLz9vYmZzcGFyYW09JnJlbWFya3M9U0c5dVowdHZibWNnU1c1MGNtRnVaWFFnVEdsdVpRJmdyb3VwPVRtOWtaV1oxYm1OMGFXOXVJRTVsZEhkdmNtdHo"))

So, unless you have an example which cannot be decoded in Workers using atob() which decodes successfully elsewhere then it sounds like your issue isn’t related and you should open a new thread rather than posting on this one.

1 Like