Skip to content

Instantly share code, notes, and snippets.

@raminious
Created September 6, 2014 19:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raminious/9fc129523afa3d351dd3 to your computer and use it in GitHub Desktop.
Save raminious/9fc129523afa3d351dd3 to your computer and use it in GitHub Desktop.
<?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