![]() |
|
首页 │ Apache │ Linux│ Java│ MySQL│ 注册│帮助 | |||
[PHP]<?php
class CONVERT{
var $matrix=array(
'0'=>'a',
'1'=>'J',
'2'=>'i',
'3'=>'f',
'4'=>'h',
'5'=>'e',
'6'=>'d',
'7'=>'b',
'8'=>'g',
'9'=>'c',
'a'=>'9',
'b'=>'j',
'c'=>'K',
'd'=>'6',
'e'=>'k',
'f'=>'9',
'g'=>'M',
'h'=>'l',
'i'=>'7',
'j'=>'5',
'k'=>'L',
'l'=>'N',
'm'=>'I',
'n'=>'m',
'o'=>'A',
'p'=>'P',
'q'=>'H',
'r'=>'1',
's'=>'n',
't'=>'4',
'u'=>'B',
'v'=>'O',
'w'=>'0',
'x'=>'2',
'y'=>'Q',
'z'=>'C',
'A'=>'3',
'B'=>'D',
'C'=>'z',
'D'=>'G',
'E'=>'y',
'F'=>'v',
'G'=>'F',
'H'=>'R',
'I'=>'w',
'J'=>'E',
'K'=>'q',
'L'=>'V',
'M'=>'U',
'N'=>'x',
'O'=>'p',
'P'=>'T',
'Q'=>'S',
'R'=>'u',
'S'=>'o',
'T'=>'W',
'U'=>'t',
'V'=>'Y',
'W'=>'r',
'X'=>'Z',
'Y'=>'X',
'Z'=>'s'
);
function encode($str){
$str2="";
for($i=0;$i
if($this->matrix[$codechar]!=""){
$str2.=$this->matrix[$codechar];
}
else{
$str2.=$codechar;
}
}
return $str2;
}
function decode($str){
$unmatrix;
$x=0;
foreach($this->matrix as $key=>$value){
echo "$x";
$x++;
$unmatrix[$value]=$key;
echo "$value-->$key";
}
echo $unmatrix['a'];
echo "".count($this->matrix)."".count($unmatrix)."";
print_r($unmatrix);
$str2="";
for($i=0;$i
if($unmatrix[$decodechar]!=""&&$unmatrix[$decodechar]!=0){
$str2.=$unmatrix[$decodechar];
}else{
$str2.=$decodechar;
}
}
return $str2;
}
}
?>[/PHP]
下面测试代码
[PHP]<?php
require("../config.php");
// require("dbi_class.php");
require("convert_class.php");
$conver=new CONVERT;
echo $conver->encode("0123456789abcdefghijklmn");
echo $conver->decode($conver->encode("0123456789abcdefghijklmn"));
?>[/PHP]

