<?php 

/*$config = array(
   "digest_alg" => "sha512",
   "private_key_bits" => 4096,
   "private_key_type" => OPENSSL_KEYTYPE_RSA,
);
$keys = openssl_pkey_new($config);
$priv = openssl_pkey_get_private($keys);
 openssl_pkey_export_to_file($priv, 'htdocs/RSAgenerator/private.pem');

 $pub = openssl_pkey_get_details($priv);
file_put_contents('public.pem', $pub['key']);*/

class RSA{
public function decryptData($encryptData){

$fp = fopen("/home/users/vaklur/vaklur.cz/web/permissions/rsa//userprivate.pem", "r");
$privateKey = fread($fp, 8192);
fclose($fp);

$res = openssl_get_privatekey($privateKey);
$cipher = base64_decode($encryptData);
openssl_private_decrypt( $cipher, $decrypted, $res, OPENSSL_PKCS1_OAEP_PADDING );

return $decrypted;
}
}

?>