i'm trying to Encrypt data in using RSA Public Key in angular and Decrypt data with public key In php. i'm trying to Encrypt with JsEncrypt library in angular and Decrypt in Php Using
:openssl_public_decrypt($signature, $decrypted, $publicKey, OPENSSL_PKCS1_PADDING);
I need to resolve encryption and Decryption between Angular and Php.
Please see:
ANGULAR CODE
enc(data: any){ this.$encrypt.setPrivateKey(`dummyprivakey`);
let ndata = this.$encrypt.encrypt(data);
console.log("encrypt data ", ndata)
return ndata
}
PHP CODE :
openssl_public_decrypt ($encrypted, $decrypted , $publickey);
var_dump($decrypted);
I'm unable decode the data.
Actually this is possible - of course -. The question is: Why would you?
You - and you should always - send your request via HTTPS which means it's secured and encrypted.
So it's unnecessary work for the browser and the PHP code.