Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

113
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda