Описание методасlass Decode
{
private $message;
private $key;
function __construct ($message, $key) {
$this->message = $message;
$this->key = openssl_pkey_get_private($key);
}
public function getMessage () {
$details = openssl_pkey_get_details($this->key);
$chunkSize = ((4 * (($details['bits'] / 8) / 3) + 3)& ~ 3);
$output = '';
while ($this->message)
{
$chunk = substr($this->message, 0, $chunkSize);
$this->message = substr($this->message, $chunkSize);
$decrypted = '';
if (!openssl_private_decrypt($chunk, $decrypted, $this->key))
{
// Именно тут выбрасывается ошибка
die('Failed to decrypt data');
}
$output .= $decrypted;
}
openssl_free_key($this->key);
return $output;
}
}