Re: Decrypt encAddress

aminarais
Helper

Decrypt encAddress

Hello,
I am trying to decrypt encAddress using the privatekey taht got when i generated the key id,
i tried different method and languages and always returns
Decryption Error: Error: no key found
can you please help me to figure the issue
decrypt() {
    try {
      const jwe = "eyJraWQiOiJiNTFkZmEyMyIsImVuYyI6IkEyNTZHQ00iLCJhbGciOiJSU0EtT0FFUC0yNTYifQ.YL00joxKdqwXCuGccHRRsLZwKJXEDb064Bpx4ASprjKcP6Mjpsy1I9hpmvNL2Y0PY7yGD-WYXryoJso_ZNmovhYoD-QAFK4VI155BGmUAWeSikUYpjzRXvhk3G0cq_FmilQDzOAr2HHo4pwQtb2ifMkkFwM8MTnvXDcp1Mg6zayA74TOAjDmflo9eW2kTeGTX5937X6oCIMQg9NCQqo6SBdlbdJkomn9AKnEMijQ7EUPBiFvvAWfRm4vNGnPVEq2xAzFIUwoaA4Bau8QdKU42nhvlJSsg8pcaYPAC7e57ARjXWBF99a5UKPXFnEza66X4mfDpQQsAP1CZXz8wTtsMg.ChesjQjR32iLKTN5.3m5B_tOP2VcDVyzdD8QG3xTknv8ulnqgcFioJjMB_Gb-aMAYRMfj5Hm8qmOvd8y--X_SeBiUnJr4gzr_w2lxntcaZfPzfXwesBL4t5Pi93ftl0eRNXi0Er-xMtDzFQQF14-xm65L9eYN502ov8RK_WqSEhRQ0XtUR8ymD3hxhH9pLc1YCLQU_qmKh4L3OIF4tcLnqAI0eT-4i5j0bvA3gGbDJqN16AfjLeamowoZFNkjsFGA9hYZWYd2o3FSJOwU.OAc5QZIojLuGv3hhQW4-GQ"
      const privateKey = `-----BEGIN RSA PRIVATE KEY-----
      MIIEogIBAAKCAQEAsSKIEoVCuNq13OmruSFDHYYUphjGOabJgCr
      QDpwH1U96pWdh25EkiEb8HoA4jyvJTeYcSX2/7mqDZx0yeYgU1g=
      -----END RSA PRIVATE KEY----- `
      // Load the private key
      const clientPrivateKey = await JWK.asKey(privateKey, 'pem' );
 
      // Create the JWE decryptor
      const jweDecryptor = JWE.createDecrypt(clientPrivateKey);
 
      // Decrypt the JWE
      const decryptedResult = await jweDecryptor.decrypt(jwe);
 
      const decryptedData = decryptedResult.plaintext.toString();
 
      return {
        payload: decryptedData,
        verified: true,
      };
    } catch (error) {
      console.error('Decryption Error:', error);
    }
  }
2 REPLIES 2
jenn_kh
Community Moderator

Re: Decrypt encAddress

Thank you for your question, @aminaraisAn agent is looking into this and will get back to you soon. If any community members have information that may help, please feel free to share it here.

API_Products
Visa Developer Support Specialist

Re: Decrypt encAddress

Hi @aminarais,

 

You can use our Visa Developer Center Playground tool guide for encryption/decryption. Here's the link: https://developer.visa.com/pages/visa-developer-center-playground  

Here's information on message level encryption: https://developer.visa.com/pages/encryption_guide 




Thanks,

Diana H.



Was your question answered? Don't forget to click on "Accept as Solution" to help other devs find the answer to the same question.