Home > Backend Development > PHP Tutorial > PHP implements base64 encoding and decoding

PHP implements base64 encoding and decoding

WBOY
Release: 2016-07-25 08:45:17
Original
1156 people have browsed it
  1. class encryptCalss
  2. {
  3. var $key=12;
  4. function encode($txt){
  5. for($i=0;$i $txt[$i]=chr(ord($txt[$i])+$this->key);
  6. }
  7. return $txt=urlencode(base64_encode(urlencode($txt)));
  8. }
  9. function decode($txt){
  10. $txt=urldecode(base64_decode($txt));
  11. for($i=0;$i $txt[$i]=chr(ord($txt[$i])-$this->key);
  12. }
  13. return $txt;
  14. }
  15. }
  16. ?>
复制代码

php


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template