本文整理汇总了PHP中Encryption::base64Encode方法的典型用法代码示例。如果您正苦于以下问题:PHP Encryption::base64Encode方法的具体用法?PHP Encryption::base64Encode怎么用?PHP Encryption::base64Encode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Encryption
的用法示例。
在下文中一共展示了Encryption::base64Encode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBase64Encode
public function testBase64Encode()
{
$string = '!!?*!~Za_-c@#$2üäas!';
self::assertSame('ISE/KiF+WmFfLWNAIyQyw7zDpGFzIQ==', base64_encode($string));
self::assertSame('ISE_KiF-WmFfLWNAIyQyw7zDpGFzIQ', Encryption::base64Encode($string));
}
示例2: encrypt
/**
* Returns a base64 encoded, openssl encrypted string with the encryption
* password and
* a salt.
*
* Do not rely on the way this is encrypted, just use it in conjunction with
* decrypt.
*
* BEWARE of any changes in different release versions because you'll might be
* unable to decrypt after a change.
*
* If the data is not a string, it gets serialized.
*
* @param mixed $data
*/
public function encrypt($data)
{
if (is_string($data)) {
$data = self::SERIALIZE_NONE . '-' . $data;
} elseif ($this->serializationFormat === self::SERIALIZE_JSON) {
$data = self::SERIALIZE_JSON . '-' . json_encode($data);
} elseif ($this->serializationFormat === self::SERIALIZE_PHP) {
$data = self::SERIALIZE_PHP . '-' . serialize($data);
}
// serialized
$nonce = $this->generateNonce($this->nonceChars);
if ($this->useMd5NotRandom) {
// Using the md5 of data as IV
$iv = substr(md5($data), 0, $this->ivMaxChars);
} else {
// Complete random IV
$iv = $this->generateNonce(is_int($this->ivMaxChars) ? $this->ivMaxChars : $this->cipherIvLength, true);
}
return ($iv ? $iv . '.' : '') . Encryption::base64Encode(openssl_encrypt($this->salt . $data . $nonce, $this->cipher, $this->password, true, $this->padIv($iv, $this->cipherIvLength)));
}