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

347
Views
Removing the non-base64 code from the FileReader without hard coding?
b64DecodeUnicode(str) {
    // Going backwards: from bytestream, to percent-encoding, to original string.
    return decodeURIComponent(atob(str).split('').map(function(c) {
        return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2);
    }).join(''));
}

I tried using atob, then I tried using the above. It's a pem file, doing:

openssl x509 -in valid.pem -text -noout 

and it gives valid output.

The text content looks like: data:application/x-x509-ca-cert;base64,QpDQXdHVVhWbFltVmp... instead of this: -----BEGIN CERTIFICATE-----... and it cannot be converted from base64.

I kept getting:

String contains an invalid character. The "data:application/x-x509-ca-cert;base64," part, is there a way to remove it from the reader.result?

const reader = new FileReader()
    reader.onload = (e) => {
    reader.result
    ...
}

I am guessing every pem file starts with "data:application/x-x509-ca-cert;base64,", but is there a way to remove it without hardcoding the string and removing that substring from the content?

I would like to avoid using:

replace('data:application/x-x509-ca-cert;base64,', '')
about 4 years ago · Juan Pablo Isaza
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!