php 字符串加密、解密类的解决办法
内容摘要
这篇文章主要为大家详细介绍了php 字符串加密、解密类的简单示例,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:
/**
对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:
/**
文章正文
这篇文章主要为大家详细介绍了php 字符串加密、解密类的简单示例,具有一定的参考价值,可以用来参考一下。
对此感兴趣的朋友,看看idc笔记做的技术笔记。经测试代码如下:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | <code class = "php" > /** * 字符串加密、解密类 * * @param * @author php教程 www.idcnote.com **/ class cryption { function en( $str , $key ) { $ret = '' ; $str = base64_encode ( $str ); for ( $i =0; $i <= strlen ( $str )-1; $i ++){ $d_str = substr ( $str , $i , 1); $int =ord( $d_str ); $int = $int ^ $key ; $hex = strtoupper ( dechex ( $int )); $ret .= $hex ; } return $ret ; } function de( $str , $key ) { $ret = '' ; for ( $i =0; $i <= strlen ( $str )-1; 0){ $hex = substr ( $str , $i , 2); $dec =hexdec( $hex ); $dec = $dec ^ $key ; $ret .= chr ( $dec ); $i = $i +2; } return base64_decode ( $ret ); } } $cryption = new cryption; /*** 代码来自php教程(www.idcnote.com) ***/ </code> |
注:关于php 字符串加密、解密类的简单示例的内容就先介绍到这里,更多相关文章的可以留意
代码注释