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

112
Views
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
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!