时间:2021-05-18
php代码类:
复制代码 代码如下:
<?php
/**
* Copyright (c) 2011 - 01 XatuDream
* XatuDream All Rights Reserved.
* Support:185390516.qzone.qq.com
* QQ:185390516
* Author:Lau Version:1.01
* Date:2010-08-12 09:28:32
*/
! defined ( 'WORKSPACE' ) && exit ( "Access Denied !" );
class MD5Crypt {
/**
* Enter description here ...
* @param unknown_type $str
* @return string
*/
public final static function mdsha($str) {
$code = substr ( md5 ( $str ), 10 );
$code .= substr ( sha1 ( $str ), 0, 28 );
$code .= substr ( md5 ( $str ), 0, 22 );
$code .= substr ( sha1 ( $str ), 16 ) . md5 ( $str );
return self::chkToken () ? $code : null;
}
/**
* Enter description here ...
* @param unknown_type $param
*/
private final static function chkToken() {
return true;
}
/**
* Enter description here ...
* @param unknown_type $txt
* @param unknown_type $encrypt_key
* @return Ambigous <string, boolean>
*/
private final static function keyED($txt, $encrypt_key) {
$encrypt_key = md5 ( $encrypt_key );
$ctr = 0;
$tmp = "";
for($i = 0; $i < strlen ( $txt ); $i ++) {
if ($ctr == strlen ( $encrypt_key ))
$ctr = 0;
$tmp .= substr ( $txt, $i, 1 ) ^ substr ( $encrypt_key, $ctr, 1 );
$ctr ++;
}
return $tmp;
}
/**
* Enter description here ...
* @param unknown_type $txt
* @param unknown_type $key
* @return string
*/
public final static function Encrypt($txt, $key) {
srand ( ( double ) microtime () * 1000000 );
$encrypt_key = md5 ( rand ( 0, 32000 ) );
$ctr = 0;
$tmp = "";
for($i = 0; $i < strlen ( $txt ); $i ++) {
if ($ctr == strlen ( $encrypt_key ))
$ctr = 0;
$tmp .= substr ( $encrypt_key, $ctr, 1 ) . (substr ( $txt, $i, 1 ) ^ substr ( $encrypt_key, $ctr, 1 ));
$ctr ++;
}
$_code = md5 ( $encrypt_key ) . base64_encode ( self::keyED ( $tmp, $key ) ) . md5 ( $encrypt_key . $key );
return self::chkToken () ? $_code : null;
}
/**
* Enter description here ...
* @param unknown_type $txt
* @param unknown_type $key
* @return Ambigous <string, boolean>
*/
public final static function Decrypt($txt, $key) {
$txt = self::keyED ( base64_decode ( substr ( $txt, 32, - 32 ) ), $key );
$tmp = "";
for($i = 0; $i < strlen ( $txt ); $i ++) {
$md5 = substr ( $txt, $i, 1 );
$i ++;
$tmp .= (substr ( $txt, $i, 1 ) ^ $md5);
}
return self::chkToken () ? $tmp : null;
}
/**
* Enter description here ...
* @var unknown_type
*/
private static $_key = 'lau';
}
?>
使用方法:
复制代码 代码如下:
<?php //Code Start
/**
* Copyright (c) 2011 XatuDream
* XatuDream All Rights Reserved.
* Support:185390516.qzone.qq.com
* QQ:185390516
* Author:LoveCrystal Version:1.01
* Date:2011-9-2 04:00:37
*/
define ( 'WORKSPACE', '.' . DIRECTORY_SEPARATOR );
header ( "Content-Type: text/html; charset=utf-8" );
include_once 'Core/Library/MD5Crypt.class.php';
$a = MD5Crypt::Encrypt ( "A", 100 );
echo "EnCode:" . $a, "<br />";
echo "DeCode:" . MD5Crypt::Decrypt ( $a, 100 );
?>
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例讲述了基于php实现的php代码加密解密类。分享给大家供大家参考,具体如下:php代码加密类,大家可以根据自己的需求进行修改,原类如下,该实例在ubun
分享2种PHP的源码加密方式,此加密方法支持任意PHP版。注意,加密后的PHP代码无需第三方工具解密,像往常一样,直接运行即可。复制代码代码如下:
本文实例讲述了PHP中加密解密函数与DES加密解密的应用,分享给大家供大家参考。具体如下:例子,php加密解密的例子加密函数:复制代码代码如下:/**功能:对字
这个C#类是一个基于Base64的加密和解密类,用户可以可以使用默认的秘钥进行加密、解密,也可以自己设定秘钥进行加密和解密,非常实用代码一:非常精简的代码///
收录了一些比较经典的PHP加密解密函数代码,分享给大家。加密解密原理一般都是通过一定的加密解密算法,将密钥加入到算法中,最终得到加密解密结果。?12345678