PHP 用base64兌現加密解密

來源:互聯網
上載者:User
PHP 用base64實現加密解密
php中用base64實現加密解密: base64_encode() 和 base64_decode() 進行加密和解密.


文法: string base64_encode ( string data )

使用 base64 對 data 進行編碼。設計此種編碼是為了使位元據可以通過非純 8-bit 的傳輸層傳輸,例如電子郵件的主體。

Base64-encoded 資料要比未經處理資料多佔用 33% 左右的空間。

文法: string base64_decode ( string encoded_data )
base64_decode() 對 encoded_data 進行解碼,返回未經處理資料,失敗則返回 FALSE。返回的資料可能是二進位的。


例子 1. base64_encode() 樣本
$str = 'This is an encoded string';
echo base64_encode($str);

?>

此例將顯示:
VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==


例子 2. base64_decode() 樣本

$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);

?>

此例將顯示:
This is an encoded string
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.