I'm trying to encrypt some strings in the frontend with javascript with the some public-private key method in which only the backend could decrypt with the private key, is this possible? how can I achieve it?
I don't mind if it has a really basic encryption as long it has a public and private key
// This is an EXAMPLE of what I want:
//Frontend code:
let message = encrypt("hello word!","public_key");
//Nodejs backend code:
let decrypt_message = decrypt(message, "private_key");
also notice that I'm already using HTTPS but having extra security doesn't hurt anyone :)
thank you in advance ♥
CryptoJS / crypto-js and JSEncrypt / jsencrypt are the libraries you can use to do so.
You need to encrypt your data encryption key to send to backend and then you can decode this on backend using Private key and encryption key.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With