当前位置: 首页>>代码示例>>PHP>>正文


PHP Encryption::base64Encode方法代码示例

本文整理汇总了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));
 }
开发者ID:enyo,项目名称:rincewind,代码行数:6,代码来源:EncryptionTest.php

示例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)));
 }
开发者ID:enyo,项目名称:rincewind,代码行数:35,代码来源:Ssl.php


注:本文中的Encryption::base64Encode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。