<?php
if (false) {
     $privateKey = openssl_pkey_new(array(
          'private_key_bits' => 512,      // Size of Key.
          'private_key_type' => OPENSSL_KEYTYPE_RSA,
     ));
     // // Save the private key to private.key file. Never share this file with anyone.
     openssl_pkey_export_to_file($privateKey, 'private.key');

     // // Generate the public key for the private key
     $a_key = openssl_pkey_get_details($privateKey);
     // // Save the public key in public.key file. Send this file to anyone who want to send you the encrypted data.
     file_put_contents('public.key', $a_key['key']);

     // // Free the private Key.
     openssl_free_key($privateKey);
}
//$fp=fopen("/opt/webbike/www/public.key","r"); 
//$pub_key=fread($fp,8192); 
//fclose($fp); 
$fp = fopen("/opt/webbike/www/private.key", "r");
$priv_key = fread($fp, 8192);
fclose($fp);

$source = "4027305002236481-721";

openssl_public_encrypt($source, $crypttext, $pub_key);

$encrypted = base64_encode($crypttext);
//print_r($publicKey);
$encrypted = "Xx3iNIlhlL5dGpXwXA9AT2NySxs2Ve6H+EOO2fFpSDDBDNE2g3tx6MWeYmMyP+dbasxdiIpGuZ9ca/gANY7etg==";
$encrypted2 = base64_decode($encrypted);
echo $pub_key;
echo $priv_key;
echo $encrypted . "\n";
// $passphrase is required if your key is encoded (suggested)

$res = openssl_get_privatekey($priv_key);
/*
* NOTE:  Here you use the returned resource value
*/
openssl_private_decrypt($encrypted2, $newsource, $res);

echo $newsource;
//phpinfo()
