PHP数字加密解密类
来源:互联网 发布:视觉健康检查数据 编辑:程序博客网 时间:2024/04/30 07:53
<?php
/* ----------------------------------------------------------------------------
* Script Name: encrypt.php
* Creation Date: 2008-4-7 10:36
* Last Modified: 2008-4-12 16:00
* Author: meyu
* Copyright (c) 2007
* Purpose: 数字字符串简易加解密
* ----------------------------------------------------------------------------*/
class Encryption {
/**
* 最终的密文代码,可设为任意不重复的10位英文字符a-zA-Z
*/
private $replacement = 'urskydMeIV';
/**
* 增加的密文第一位,可设为1位除0以外的整数,即 1-9
*/
private $prefix = "8";
/**
* 公钥,长度小于8位的正整数
*/
private $match = "111111";
/**
* 转换后对照数组
*/
private $replaceenc;
private $replacedec;
function __construct() {
for($i =0; $i < 10; $i++) {
$this->replaceenc['/'.$i.'/'] = $this->replacement{$i};
$this->replacedec['/'.$this->replacement{$i}.'/'] = $i;
}
}
public function encrypt($str) {
return preg_replace(
array_keys($this->replaceenc),
$this->replaceenc,
$this->mynotin(preg_replace("/(.)(.)/", "${2}${1}", $str))
);
}
public function decrypt($str) {
return preg_replace("/(.)(.)/", "${2}${1}",
$this->mynotout(preg_replace(array_keys($this->replacedec),$this->replacedec,$str))
);
}
private function mynotin($str) {
$str_out = "";
$i = 0;
while(isset($str{7*$i})) {
$str_out .= (($this->prefix.substr($str, $i*7, 7))+0)^$this->match;
$i++;
}
return $str_out;
}
private function mynotout($str) {
$str_out = "";
$i = 0;
while(isset($str{8*$i})) {
$str_out .= substr((substr($str, $i*8, 8)+0)^$this->match, 1);
$i++;
}
return $str_out;
}
}
?>
- PHP数字加密解密类
- 数字加密解密类-php
- PHP加密解密类(密文只有大小写字母和数字),支持中文加密
- php加密解密功能类
- php AES128加密解密类的使用
- 一个php加密解密实用类
- php加密解密
- php加密解密2
- PHP加密解密
- Php Mcrypt 加密解密
- PHP 加密解密函数
- php加密解密技术
- php--rc4加密解密
- PHP加密/解密
- PHP加密解密
- PHP加密解密
- php AES加密解密
- PHP加密解密函数
- 北邮08复试模拟problem B
- 软件测试的一些好书
- 软件测试入门书籍
- nice day
- 结束负分的日子
- PHP数字加密解密类
- 找啊!找啊!找不到工作(中)——漂在中关村(3)
- C#正则表达式编程(四):正则表达式
- Flex Builder cannot locate the required debug version of the Flash Player problem
- Gartner:商业智能(BI)的五大预测
- MFC遍历文件夹
- Android HomeScreen Launcher解析(一)
- 我来了
- 轻松定制home screen