Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to RSA decrypt in PHP openssl #45

Open
swaranbm opened this issue Jan 15, 2024 · 0 comments
Open

Unable to RSA decrypt in PHP openssl #45

swaranbm opened this issue Jan 15, 2024 · 0 comments

Comments

@swaranbm
Copy link

swaranbm commented Jan 15, 2024

Decryption using PHP Openssl 1.1.1w fails for a Cipher encrypted using hybrid-crypto-js v4.2.0.
I have verified that the key pair matches.
Is there anything else I am missing here? Kindly help.

JavaScript:

const publicKey = "returned from php reading public_key.pem";
const plainText = "plain text here";
var crypt = new Crypt();
var encryptedText = crypt.encrypt(publicKey, plainText);
// send JSON.parse(encryptedText).cipher to php

PHP:

$privateKey = file_get_contents("./private_key.pem");
$ret = openssl_private_decrypt(base64_decode($_GET['encrypted_text']), $decryptedText, $privateKey);
if (!$ret) echo "decryption failed";
else echo "Decrypted Text: " . ($decryptedText);

@swaranbm swaranbm changed the title Unable to decrypt in PHP openssl Unable to RSA decrypt in PHP openssl Jan 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant