Port of Phalcon 2.0.x Phalcon\Crypt. Provides encryption facilities to phalcon applications. $crypt = new \Phalcon\Legacy\Crypt(); $key = 'le password'; $text = 'This is a secret text'; $encrypted = $crypt->encrypt($text, $key); echo $crypt->decrypt($encrypted, $key);
Inheritance: implements Phalcon\Legacy\CryptInterface
コード例 #1
0
ファイル: CryptTest.php プロジェクト: phalcon/incubator
 /**
  * Tests the encryption base 64
  *
  * @author Nikolaos Dimopoulos <*****@*****.**>
  * @since  2014-10-17
  */
 public function testCryptEncryptBase64()
 {
     $this->specify("encryption base 64does not return correct results", function () {
         $crypt = new Crypt();
         $crypt->setPadding(Crypt::PADDING_ANSI_X_923);
         $key = substr('phalcon notice 13123123', 0, 16);
         $expected = 'https://github.com/phalcon/cphalcon/issues?state=open';
         $encrypted = $crypt->encryptBase64($expected, substr($key, 0, 16));
         expect($crypt->decryptBase64($encrypted, $key))->equals($expected);
         $encrypted = $crypt->encryptBase64($expected, $key, true);
         expect($crypt->decryptBase64($encrypted, $key, true))->equals($expected);
     });
 }