]> git.mxchange.org Git - friendica-addons.git/blob - securemail/vendor/singpolyma/openpgp-php/lib/openpgp_mcrypt_wrapper.php
securemail: update pgp library
[friendica-addons.git] / securemail / vendor / singpolyma / openpgp-php / lib / openpgp_mcrypt_wrapper.php
1 <?php
2
3 if(function_exists('mcrypt_encrypt') && defined('MCRYPT_MODE_CFB')) {
4   class MCryptWrapper {
5     public $cipher, $key, $iv, $key_size, $block_size;
6
7
8     function __construct($cipher) {
9       $this->cipher = $cipher;
10       $this->key_size = mcrypt_module_get_algo_key_size($cipher);
11       $this->block_size = mcrypt_module_get_algo_block_size($cipher);
12       $this->iv = str_repeat("\0", mcrypt_get_iv_size($cipher, 'ncfb'));
13     }
14
15     function setKey($key) {
16       $this->key = $key;
17     }
18
19     function setIV($iv) {
20       $this->iv = $iv;
21     }
22
23     function encrypt($data) {
24       return mcrypt_encrypt($this->cipher, $this->key, $data, 'ncfb', $this->iv);
25     }
26
27     function decrypt($data) {
28       return mcrypt_decrypt($this->cipher, $this->key, $data, 'ncfb', $this->iv);
29     }
30   }
31 }