class:
<?php
/*
* @package "Gludoe CMS"
* @version 1.0.1
* @authors "Robert Pettet"
* @support https://www.gludoe.com/
* @licence https://www.gludoe.com/commons/licence-1.0.0.txt
*/
if (!defined('_ROOT'))
exit(header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'));
class Blowfish {
private $key;
private $iv;
public function __construct($key, $iv) {
$this->key = $key;
$this->iv = $iv;
}
public function encrypt($data) {
return mcrypt_encrypt(MCRYPT_BLOWFISH, $this->key, $data, MCRYPT_MODE_CBC, $this->iv);
}
public function decrypt($data) {
return mcrypt_decrypt(MCRYPT_BLOWFISH, $this->key, $data, MCRYPT_MODE_CBC, $this->iv);
}
}
?>
example:
$blowfish = new blowfish('DfRgBWE4Y4T7UgTWEdFP1Y','85440934');
$data = $blowfish->encrypt('testString');
echo $blowfish->decrypt($data);
//Output: testString












