Example #1
0
 /**
  * @requires extension mcrypt
  */
 public function testEncryptBase64()
 {
     $crypt = new \Phalcon\Crypt();
     $crypt->setPadding(\Phalcon\Crypt::PADDING_ANSI_X_923);
     $key = substr('phalcon notice 13123123', 0, 16);
     $text = 'https://github.com/phalcon/cphalcon/issues?state=open';
     $encrypted = $crypt->encryptBase64($text, substr($key, 0, 16));
     $actual = $crypt->decryptBase64($encrypted, $key);
     $this->assertEquals($actual, $text);
     $encrypted = $crypt->encryptBase64($text, $key, TRUE);
     $actual = $crypt->decryptBase64($encrypted, $key, TRUE);
     $this->assertEquals($actual, $text);
 }
Example #2
0
<?php

//Create an instance
$crypt = new Phalcon\Crypt();
$key = 'le password';
$text = 'This is a secret text';
$encrypt = $crypt->encryptBase64($text, $key);
echo $crypt->decryptBase64($text, $key);
Example #3
0
 /**
  * Return crypt password
  *
  * @return string
  */
 public function getCryptValue()
 {
     //Create an instance
     $crypt = new \Phalcon\Crypt();
     $crypt->setCipher($this->_cryptType);
     $key = \Engine\Tools\String::generateStringTemplate($this->_keyTemplate, $this->_form->getData(), '{', '}');
     $value = $this->_element->getValue();
     return $crypt->encryptBase64($value, $key);
 }
Example #4
0
<?php

//Create an instance
$encryption = new Phalcon\Crypt();
$key = 'le password';
$text = 'This is a secret text';
$encrypt = $encryption->encryptBase64($text, $key);
echo $encryption->decryptBase64($text, $key);