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

272
Views
Cómo descifrar AES SubtleCrypto [window.subtle.crypto] en CryptoJS

Estoy intentando migrar de solo navegador window.subtle.crypto a CryptoJS para que esté disponible universalmente en todas las plataformas que usan Expo.

Esencialmente: window.subtle.encrypt({name: AES-GCM}) -> CryptoJS.AES.decrypt

Para los datos cifrados existentes, CryptoJS debería poder descifrarlos utilizando la clave generada por AES desde window.subtle.generateKey, por lo que el método para window.subtle.encrypt no se puede cambiar y se hace como se describe a continuación.

Quiero descifrar el window.subtle.encrypt cifrado en CryptoJS.AES.decrypt de CryptoJS.AES.decrypt

así que para esto, he escrito este código de prueba:

 const text = "This is an encrypted message"; const generateKey = async () => { const key = await window.crypto.subtle.generateKey({ name: "AES-GCM", length: 128 }, true, ["encrypt", "decrypt"]); const key_exported = await window.crypto.subtle.exportKey("jwk", key); return key_exported.k; } const printCurrent = async () => { let kkey = await generateKey(); await window.crypto.subtle.importKey( "jwk", { k: kkey, alg: "A128GCM", ext: true, key_ops: ["encrypt", "decrypt"], kty: "oct", }, { name: "AES-GCM", length: 128 }, false, ["encrypt", "decrypt"] ).then(function(key){ window.crypto.subtle.encrypt({ name: "AES-GCM", iv: new Uint8Array(12) }, key, new TextEncoder().encode(JSON.stringify(text))).then( function(encryptedObject){ const cryptojs = CryptoJS.AES.decrypt(encryptedObject,key,{iv: new Uint8Array(12)); console.log("cryptojs: ", cryptojs.toString(CryptoJS.enc.Utf8)); }); } ); } printCurrent();

He visto que CryptoJS solo acepta WordArray, y la salida del objeto cifrado ['encryptedObject'] de la criptografía sutil es ArrayBuffer [tamaño 46], he intentado convertir ArrayBuffer a WordArray a través de CryptoJS.lib.WordArray.create(encryptedObject) pero todavía sin suerte.

Cualquier ayuda u orientación es apreciada, ¡muchas gracias!

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!