# Payment payload encryption. HELP.

**URL:** <https://forum.codewithmosh.com/t/payment-payload-encryption-help/604>\
**Category:** React Native\
**Created:** [November 10, 2020, 5:27am UTC](https://forum.codewithmosh.com/t/payment-payload-encryption-help/604 "2020-11-10T05:27:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidosunkeye](https://avatars.discourse-cdn.com/v4/letter/d/71e660/32.png) [@davidosunkeye](https://forum.codewithmosh.com/u/davidosunkeye)\
**Post date:** [November 10, 2020, 5:27am UTC](https://forum.codewithmosh.com/t/payment-payload-encryption-help/604/1 "2020-11-10T05:27:04Z")

</div>

"I am trying to integrate payment to my react-native app but the payment handler wants me to encrypt my payment data encrypt before the payment can be sent to them for processing.

Message on their site:

function encrypt(key, text) {  
var forge = require(“node-forge”);  
var cipher = forge.cipher.createCipher(  
“3DES-ECB”,  
forge.util.createBuffer(key)  
);  
cipher.start({ iv: “” });  
cipher.update(forge.util.createBuffer(text, “utf-8”));  
cipher.finish();  
var encrypted = cipher.output;  
return forge.util.encode64(encrypted.getBytes());  
}

PLEASE IDEA OR TUTORIAL ABOUT THIS?"

---

<div class="post-metadata">

**Author:** ![Spark](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@Spark](https://forum.codewithmosh.com/u/Spark)\
**Post date:** [November 15, 2020, 8:04am UTC](https://forum.codewithmosh.com/t/payment-payload-encryption-help/604/2 "2020-11-15T08:04:54Z")

</div>

Looks like you need to execute the function they have displayed on their website before sending the payload.

For that, as is apparent from the given code snippet, you need to download the package **node-forge** from npm.

Then write this function in your js file, and pass a key and text as parameters. The text is the payload you want to encrypt.

Then take the data returned from the last line of the function and send it to the external payment service that you’re using.
