Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

349
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda