本文整理汇总了PHP中Crypto::aes128cbcDecrypt方法的典型用法代码示例。如果您正苦于以下问题:PHP Crypto::aes128cbcDecrypt方法的具体用法?PHP Crypto::aes128cbcDecrypt怎么用?PHP Crypto::aes128cbcDecrypt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Crypto
的用法示例。
在下文中一共展示了Crypto::aes128cbcDecrypt方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: unwrap
/**
* {@inheritDoc}
*/
public function unwrap($in, $maxAgeSec)
{
//TODO remove this once we have a better way to generate a fake token
// in the example files
if (Config::get('allow_plaintext_token') && count(explode(':', $in)) == 6) {
$data = explode(":", $in);
$out = array();
$out['o'] = $data[0];
$out['v'] = $data[1];
$out['a'] = $data[2];
$out['d'] = $data[3];
$out['u'] = $data[4];
$out['m'] = $data[5];
} else {
//TODO Exception handling like JAVA
$bin = base64_decode($in);
$cipherText = substr($bin, 0, strlen($bin) - Crypto::$HMAC_SHA1_LEN);
$hmac = substr($bin, strlen($cipherText));
Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
$plain = Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
$out = $this->deserialize($plain);
$this->checkTimestamp($out, $maxAgeSec);
}
return $out;
}
示例2: testAes128
/**
* Tests Crypto::aes128cbcEncrypt()
*/
public function testAes128()
{
$string = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit';
$key = 'Aliquam erat volutpat';
$encrypted = Crypto::aes128cbcEncrypt($key, $string);
$decrypted = Crypto::aes128cbcDecrypt($key, $encrypted);
$this->assertEquals($decrypted, $string);
}
示例3: decrypt
public static function decrypt($key, $text)
{
if (extension_loaded('mcrypt')) {
return Crypto::aes128cbcDecrypt($key, $text);
}
$iv = substr($text, 0, 8);
$encrypted = substr($text, 8, strlen($text));
$blowfish = Crypt_Blowfish::factory('cbc', $key, $iv);
return base64_decode($blowfish->decrypt($encrypted));
}
示例4: unwrap
/**
* {@inheritDoc}
*/
public function unwrap($in, $maxAgeSec)
{
//TODO remove this once we have a better way to generate a fake token in the example files
if ($this->allowPlaintextToken && count(explode(':', $in)) >= 7) {
//Parses the security token in the form st=o:v:a:d:u:m:c
$data = $this->parseToken($in);
$out = array();
$out['o'] = $data[0];
$out['v'] = $data[1];
$out['a'] = $data[2];
$out['d'] = $data[3];
$out['u'] = $data[4];
$out['m'] = $data[5];
} else {
$bin = base64_decode($in);
if (is_callable('mb_substr')) {
$cipherText = mb_substr($bin, 0, -Crypto::$HMAC_SHA1_LEN, 'latin1');
$hmac = mb_substr($bin, mb_strlen($cipherText, 'latin1'), Crypto::$HMAC_SHA1_LEN, 'latin1');
} else {
$cipherText = substr($bin, 0, -Crypto::$HMAC_SHA1_LEN);
$hmac = substr($bin, strlen($cipherText));
}
Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
if (!function_exists('mcrypt_module_open') && $this->allowPlaintextToken) {
$plain = base64_decode($cipherText);
} else {
$plain = Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
}
$out = $this->deserialize($plain);
$this->checkTimestamp($out, $maxAgeSec);
}
return $out;
}
示例5: unwrap
/**
* {@inheritDoc}
*/
public function unwrap($in, $maxAgeSec)
{
//TODO remove this once we have a better way to generate a fake token in the example files
if ($this->allowPlaintextToken && count(explode(':', $in)) == 6) {
$data = explode(":", $in);
$out = array();
$out['o'] = $data[0];
$out['v'] = $data[1];
$out['a'] = $data[2];
$out['d'] = $data[3];
$out['u'] = $data[4];
$out['m'] = $data[5];
} else {
$bin = base64_decode($in);
$cipherText = substr($bin, 0, strlen($bin) - Crypto::$HMAC_SHA1_LEN);
$hmac = substr($bin, strlen($cipherText));
Crypto::hmacSha1Verify($this->hmacKey, $cipherText, $hmac);
if (!function_exists('mcrypt_module_open') && $this->allowPlaintextToken) {
$plain = base64_decode($cipherText);
} else {
$plain = Crypto::aes128cbcDecrypt($this->cipherKey, $cipherText);
}
$out = $this->deserialize($plain);
$this->checkTimestamp($out, $maxAgeSec);
}
return $out;
}