Created
September 6, 2014 19:45
-
-
Save raminious/9fc129523afa3d351dd3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Cipher extends CApplicationComponent{ | |
private $securekey, $iv; | |
public function init(){ | |
$this->securekey = hash('sha256', 'SADFo92j!!zVnz@Sj!39IU%YGvi^6eL8&v6*Rv(JH8)Cytuiouh547vCytdyUFl76R', true); | |
$this->iv = mcrypt_create_iv(32); | |
} | |
public function encrypt($input) { | |
return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->securekey, $input, MCRYPT_MODE_ECB, $this->iv)); | |
} | |
public function decrypt($input) { | |
return trim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->securekey, base64_decode($input), MCRYPT_MODE_ECB, $this->iv)); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment