Phalcon\Legacy\Crypt::setPadding PHP Method

setPadding() public method

Changes the padding scheme used
public setPadding ( integer $scheme ) : Phalcon\Legacy\CryptInterface
$scheme integer
return Phalcon\Legacy\CryptInterface
    public function setPadding($scheme)
    {
        $this->padding = $scheme;
        return $this;
    }

Usage Example

Example #1
0
 /**
  * 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);
     });
 }