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

114
Vistas
decrypt an ArrayBuffer with sjcl.decrypt which is not a json

Before I encrypted my data I've put it into this format:

let a = new TextEncoder().encode(JSON.stringify(data))

After encryption, I've encoded it for storing that way:

let b = new Uint8Array(a)

and finally converted it into base64.

Now I want to decrypt my data with sjcl library function sjcl.decrypt.

  • I've my privateKey as JSON string.
  • I've my cipher as Uint8Array.
  • I've put the cipher into it's original codec after encryption with: new TextDecoder().decode(cipher)

What now? sjcl throws, json decode: this isn't json!. Understood, because my encrypted data is an ArrayBuffer.

So my question: is it possible to decrypt my case with sjcl? When looking into sjcl source it seems, that decrypt needs a JSON. But I have no JSON.

Edit the encryption process is not possible.

Thank you!

------------ UPDATE ------------

That's how the keyPair is generated:

await window.crypto.subtle.generateKey({
        name: "RSA-OAEP",
        modulusLength: 2048,
        publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
        hash: { name: "SHA-256" },
    }, true, ["encrypt", "decrypt"]);

Then the key is exported like that (I receive that key):

await window.crypto.subtle.exportKey(
        "jwk",
        keyPair.privateKey
    );

Ecryption with public key:

await window.crypto.subtle.encrypt({ name: "RSA-OAEP" }, publicKey, data);

In my application I have no access to WebCrypto Api. Tried out sjcl library, but it seems rsa encryptio/decryption is not possible. Tested with jsrsasign library, but it does not support jwk exported keys. Can I convert jwk to pkcs8?

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