Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

271
Views
Why does atob fail in Safari and Chrome on this Base 64 string?

Here is an example bit of Javascript to reproduce the issue:

let a = "qNqrdXUrk5S7dCM1MAYH3qSVDXznb-6prQoGqiACR10=";
console.log(atob(a));

In Safari we get:

Invalid Character Error: the string contains an invalid character.

In Chrome we get:

Uncaught DOMException: Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.

I can decode the above string on base64decode.org. By the way the value is intended to be a random sequence of bytes, not any sort of human readable string. atob ought to handle that.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

From the "Design" section of that same page:

MIME's Base64 implementation uses A-Z, a-z, and 0-9 for the first 62 values, as well as "+" and "/" for the last two. Other variations, usually derived from Base64, share this property but differ in the symbols chosen for the last two values; an example is the URL and filename safe "RFC 4648 / Base64URL" variant, which uses "-" and "_".

JS uses the MIME-based encoding, and therefore the - in your initial string is invalid. It likely works on the decoder on the site by detecting which characters are in the input string and choosing the proper decoding format versus blindly using atob().

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!