Encrypt in React Native, decrypt in Java

Viewed 717

I need an easy solution for encrypt a string in AES from my React Native app, send to the server and the decrypt from there with Java. I found some solutions but I am not able to make it works... Thanks a lot!

1 Answers

For the Javascript/React Native side I've used crypto-js before which should just be a couple lines of code to implement.

npm install crypto-js

Then in your code

import AES from 'crypto-js/aes'

const stringToEncrypt = 'my string';
const secretKey = 'secret key 123';
const encryptedString = AES.encrypt(stringToEncrypt, secretKey).toString();

Then you can send encryptedString to your server, prefereably via https using something like Axios or Fetch

Related