• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

支持中文的php加密解密类代码_php技巧

php 搞代码 3年前 (2022-01-26) 78次浏览 已收录 0个评论

php代码类:

 <BR><?php <BR>/** <BR>* Copyright (c) 2011 - 01 XatuDream <BR>* XatuDream All Rights Reserved. <BR>* Support:185390516.qzone.qq.com <BR>* QQ:185390516 <BR>* Author:Lau Version:1.01 <BR>* Date:2010-08-12 09:28:32 <BR>*/ <BR>! defined ( 'WORKSPACE' ) && exit ( "Access Denied !" ); <BR>class MD5Crypt { <BR>/** <BR>* Enter description here ... <BR>* @param unknown_type $str <BR>* @return string <BR>*/ <BR>public final static function mdsha($str) { <BR>$code = substr ( md5 ( $str ), 10 ); <BR>$code .= substr ( sha1 ( $str ), 0, 28 ); <BR>$code .= substr ( md5 ( $str ), 0, 22 ); <BR>$code .= substr ( sha1 ( $str ), 16 ) . md5 ( $str ); <BR>return self::chkToken () ? $code : null; <BR>} <BR>/** <BR>* Enter description here ... <BR>* @param unknown_type $param <BR>*/ <BR>private final static function chkToken() { <BR>return true; <BR>} <BR>/** <BR>* Enter description here ... <BR>* @param unknown_type $txt <BR>* @param unknown_type $encrypt_key <BR>* @return Ambigous  <BR>*/ <BR>private final static function keyED($txt, $encrypt_key) { <BR>$encrypt_key = md5 ( $encrypt_key ); <BR>$ctr = 0; <BR>$tmp = ""; <BR>for($i = 0; $i < strlen ( $txt ); $i ++) { <BR>if ($ctr == strlen ( $encrypt_key )) <BR>$ctr = 0; <BR>$tmp .= substr ( $txt, $i, 1 ) ^ substr ( $encrypt_key, $ctr, 1 ); <BR>$ctr ++; <BR>} <BR>return $tmp; <BR>} <BR>/** <BR>* Enter description here ... <BR>* @param unknown_type $txt <BR>* @param unknown_type $key <BR>* @return string <BR>*/ <BR>public final static function Encrypt($txt, $key) { <BR>srand ( ( double ) microtime () * 1000000 ); <BR>$encrypt_key = md5 ( rand ( 0, 32000 ) ); <BR>$ctr = 0; <BR>$tmp = ""; <BR>for($i = 0; $i < strlen ( $txt ); $i ++) { <BR>if ($ctr == strlen ( $encrypt_key )) <BR>$ctr = 0; <BR>$tmp .= substr ( $encrypt_key, $ctr, 1 ) . (substr ( $txt, $i, 1 ) ^ substr ( $encrypt_key, $ctr, 1 )); <BR>$ctr ++; <BR>} <BR>$_code = md5 ( $encrypt_key ) . base64_encode ( self::keyED ( $tmp, $key ) ) . md5 ( $encrypt_key . $key ); <BR>return self::chkToken () ? $_code : null; <BR>} <BR>/** <BR>* Enter description here ... <BR>* @param unknown_type $txt <BR>* @param unknown_type $key <BR>* @return Ambigous  <BR>*/ <BR>public final static function Decrypt($txt, $key) { <BR>$txt = self::keyED ( base64_decode ( substr ( $txt, 32, - 32 ) ), $key ); <BR>$tmp = ""; <BR>for($i = 0; $i < strlen ( $txt ); $i ++) { <BR>$md5 = substr ( $txt, $i, 1 ); <BR>$i ++; <BR>$tmp .= (substr ( $txt, $i, 1 ) ^ $md5); <BR>} <BR>return self::chkToken () ? $tmp : null; <BR>} <BR>/** <BR>* Enter description here ... <BR>* @var unknown_type <BR>*/ <BR>private static $_key = 'lau'; <BR>} <BR>?> <BR>


使用方法:

 <BR><?php //Code Start <BR>/** <BR>* Copyright (c) 2011 XatuDream <BR>* XatuDream All Rights Reserved. <BR>* Support:185390516.qzone.qq.com <BR>* QQ:185390516 <BR>* Author<strong style="color:transparent">本文来源gaodai#ma#com搞@@代~&码*网/</strong><strong>搞gaodaima代码</strong>:LoveCrystal Version:1.01 <BR>* Date:2011-9-2 04:00:37 <BR>*/ <BR>define ( 'WORKSPACE', '.' . DIRECTORY_SEPARATOR ); <BR>header ( "Content-Type: text/html; charset=utf-8" ); <BR>include_once 'Core/Library/MD5Crypt.class.php'; <BR>$a = MD5Crypt::Encrypt ( "A", 100 ); <BR>echo "EnCode:" . $a, "<br />"; <BR>echo "DeCode:" . MD5Crypt::Decrypt ( $a, 100 ); <BR>?> <BR>

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:支持中文的php加密解密类代码_php技巧
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址