Phalcon\Legacy\Crypt::decryptBase64 PHP Method

decryptBase64() public method

Decrypt a text that is coded as a base64 string
public decryptBase64 ( string $text, mixed $key = null, boolean $safe = false ) : string
$text string
$key mixed
$safe boolean
return string
    public function decryptBase64($text, $key = null, $safe = false)
    {
        if ($safe) {
            return $this->decrypt(base64_decode(strtr($text, "-_", "+/")), $key);
        }
        return $this->decrypt(base64_decode($text), $key);
    }

Usage Example

Beispiel #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);
     });
 }