Пример #1
0
 public function create()
 {
     $algo = 'twofish';
     $mode = 'cbc';
     $iv = mcrypt_create_iv(mcrypt_get_iv_size($algo, $mode));
     $hash = 'sha256';
     $password = $this->password;
     $message = $this->message;
     $key = hash($hash, $password, false);
     $td = mcrypt_module_open($algo, '', $mode, '');
     mcrypt_generic_init($td, $password, $iv);
     $encmsg = mcrypt_generic($td, $message);
     mcrypt_generic_deinit($td);
     mcrypt_module_close($td);
     $spastie = new Spastie();
     $spastie->key = $key;
     $spastie->msg = base64_encode($encmsg);
     $spastie->iv = bin2hex($iv);
     return $spastie->save();
 }