forked from friendica/friendica-addons
Hypolite Petovan
c18e0dc66a
- Add missing use statement in SecureTestEmail - Address https://github.com/friendica/friendica/issues/12011#issuecomment-1321196332 - phpseclib version 3 dependency is implied from the core so it is removed from the addon
43 lines
983 B
PHP
43 lines
983 B
PHP
<?php
|
|
|
|
if(function_exists('openssl_encrypt')) {
|
|
class OpenSSLWrapper {
|
|
public $cipher, $key, $iv, $key_size, $block_size;
|
|
|
|
|
|
function __construct($cipher) {
|
|
if($cipher != "CAST5-CFB") throw Exception("OpenSSLWrapper is only used for CAST5 right now");
|
|
|
|
$this->cipher = $cipher;
|
|
$this->key_size = 16;
|
|
$this->block_size = 8;
|
|
$this->iv = str_repeat("\0", 8);
|
|
}
|
|
|
|
function getBlockLengthInBytes()
|
|
{
|
|
return $this->block_size;
|
|
}
|
|
|
|
function getKeyLength() {
|
|
return $this->key_size << 3;
|
|
}
|
|
|
|
function setKey($key) {
|
|
$this->key = $key;
|
|
}
|
|
|
|
function setIV($iv) {
|
|
$this->iv = $iv;
|
|
}
|
|
|
|
function encrypt($data) {
|
|
return openssl_encrypt($data, $this->cipher, $this->key, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $this->iv);
|
|
}
|
|
|
|
function decrypt($data) {
|
|
return openssl_decrypt($data, $this->cipher, $this->key, OPENSSL_RAW_DATA|OPENSSL_ZERO_PADDING, $this->iv);
|
|
}
|
|
}
|
|
}
|