- Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.15
- Parse error: syntax error, unexpected 'public' (T_PUBLIC) in /in/UIYb3 on line 3
Process exited with code 255.
<?php
public $pubkey = '...public key here...';
public $privkey = '...private key here...';
function encrypt($data)
{
if (openssl_public_encrypt($data, $encrypted, $this->pubkey))
$data = base64_encode($encrypted);
else
throw new Exception('Unable to encrypt data. Perhaps it is bigger than the key size?');
return $data;
}
function decrypt($data)
{
if (openssl_private_decrypt(base64_decode($data), $decrypted, $this->privkey))
$data = $decrypted;
else
$data = '';
return $data;
}
$e = encrypt('hello');
var_dump($e);
var_dump(decrypt($e));