2

I get a resource(2) of type (OpenSSL key) Resource id #2 error when running the decryption.php file can anyone help?

My decryption.php file:

<?php
{
if (isset($_POST['en_text']) && isset($_POST['key_file']))
$passphrase = $_POST['password'];
$encrypted = $_POST['en_text'];    
$key_file = $_POST['key_file'];
$privateKey = openssl_pkey_get_private( $key_file , $passphrase );
$sensitiveData =  "";
openssl_private_decrypt( $encrypted , $sensitiveData ,  $privateKey );
echo "$sensitiveData";
}
?>

and my form.html

    <form id="frm1" method="post"  action="decryption1.php" >
    link to .pem file:<input type="text" value="" name="key_file" /><br />
    Encrypted Text:<input type="text" value="" name="en_text"  /><br />
    Password: <input type="password" value="" name="password"  /><br />
    <input type="submit" value="Decrypt" id="submit" />
    </form>

I get an error

resource(2) of type (OpenSSL key) Resource id #2. The link to my pem is file:///home/ssl/private.pem can anyone help?

Shawn Mehan
  • 4,513
  • 9
  • 31
  • 51
david david
  • 185
  • 2
  • 14
  • Formatting, removed the personal email from the OP. – Shawn Mehan Apr 24 '17 at 20:39
  • 1
    Did you post abbreviated code, or is what was posted above _really_ your code? The output you received `resource(2) of type (OpenSSL key) Resource id #2.` is what I would expect from `echo $privateKey`, rather than from `$sensitiveData`. – Michael Berkowski Apr 24 '17 at 20:43

0 Answers0