本文整理匯總了PHP中Crypto::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP Crypto::get方法的具體用法?PHP Crypto::get怎麽用?PHP Crypto::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Crypto
的用法示例。
在下文中一共展示了Crypto::get方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: decrypt
/**
* Decrypt data originally returned from ::encrypt() using the two keys
* that were originially passed into the ::encrypt() method.
*
* Parameters:
* ciphertext - (string<binary>) Unencoded data returned from the
* ::encrypt() method
* key - (string) master key used for the encryption originally
* skey - (string_ sub key or namespace used originally for the
* encryption
*/
function decrypt($ciphertext, $key, $skey = 'encryption')
{
if (!$key || !$ciphertext || $ciphertext[0] != '$') {
return false;
}
list(, $crypt, $ciphertext) = explode('$', $ciphertext, 3);
//Get crypto.... based on crypt tag.
if (!$crypt || !($crypto = Crypto::get($crypt)) || !$crypto->exists()) {
return false;
}
$crypto->setKeys($key, $skey);
return $crypto->decrypt(base64_decode($ciphertext));
}