Atob api question

Hi!

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:
NDIuMTU5Ljk0LjE1MTo1MDAwMDpvcmlnaW46cmM0LW1kNTpwbGFpbjpUbTlrWldaMWJtTjBhVzl1U0c5dVowdHZibWRDUzFobmEzQTJlbkpFYjNwU0lRLz9vYmZzcGFyYW09JnJlbWFya3M9U0c5dVowdHZibWNnU1c1MGNtRnVaWFFnVEdsdVpRJmdyb3VwPVRtOWtaV1oxYm1OMGFXOXVJRTVsZEhkdmNtdHo

NDIuMTU5Ljk0LjE1MTo1MDAwMTpvcmlnaW46cmM0LW1kNTpwbGFpbjpUbTlrWldaMWJtTjBhVzl1U21Gd1lXNXRjWEZVWWtnM1lXNW1SMVZJSVEvP29iZnNwYXJhbT0mcmVtYXJrcz1TbUZ3WVc0Z1NXNTBjbUZ1WlhRZ1RHbHVaUSZncm91cD1UbTlrWldaMWJtTjBhVzl1SUU1bGRIZHZjbXR6

NDIuMTU5Ljk0LjE1MTo1MDAwMjpvcmlnaW46cmM0LW1kNTpwbGFpbjpUbTlrWldaMWJtTjBhVzl1VTJsdVoyRndiM0psWm1aT2MxRlFPSGxvWjFCSVUwQS8_b2Jmc3BhcmFtPSZyZW1hcmtzPVUybHVaMkZ3YjNKbElFSmhZMnQxY0NCT1pYUjNiM0pyJmdyb3VwPVRtOWtaV1oxYm1OMGFXOXVJRTVsZEhkdmNtdHo

NDIuMTU5Ljk0LjE1MTo1MDAwMzpvcmlnaW46cmM0LW1kNTpwbGFpbjpUbTlrWldaMWJtTjBhVzl1VlZOQlQxcFlVV2hNTkVWdmVXRk5SaUUvP29iZnNwYXJhbT0mcmVtYXJrcz1WVzVwZEdWa0lGTjBZWFJsY3lCSmJuUnlZVzVsZENCTWFXNWwmZ3JvdXA9VG05a1pXWjFibU4wYVc5dUlFNWxkSGR2Y210eg

1 Like

Interesting question.

Actually, from this url, cryptoservices.security.cfdata.org/

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"))

42.159.94.151:50000:origin:rc4-md5:plain:Tm9kZWZ1bmN0aW9uSG9uZ0tvbmdCS1hna3A2enJEb3pSIQ/?obfsparam=&remarks=SG9uZ0tvbmcgSW50cmFuZXQgTGluZQ&group=Tm9kZWZ1bmN0aW9uIE5ldHdvcmtz

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