A simple php encryption and decryption function (dynamic encryption ). Copy the code as follows: functionencode_pass ($ tex, $ key, $ typeencode) {$ chrArrarray (a, B, c, d, e, f, g, h, I, j, k, l, m, n, o, p, q, r, s, t, u, v, w
The code is as follows:
Function encode_pass ($ tex, $ key, $ type = "encode "){
$ ChrArr = array ('A', 'B', 'C', 'D', 'e', 'F', 'G', 'H ', 'I', 'J', 'K', 'L', 'M', 'n', 'O', 'P', 'Q', 'R ','s ', 'T', 'u', 'V', 'W', 'X', 'y', 'z ',
'A', 'B', 'C', 'D', 'e', 'e', 'F', 'G', 'H', 'I', 'J ', 'K', 'L', 'M', 'n', 'O', 'P', 'Q', 'R', 'S', 'T ', 'U', 'V', 'W', 'X', 'y', 'z ',
'0', '1', '2', '3', '4', '5', '6', '7', '8 ', '9 ');
If ($ type = "decode "){
If (strlen ($ tex) <14) return false;
$ Verity_str = substr ($ tex, 0, 8 );
$ Tex = substr ($ tex, 8 );
If ($ verity_str! = Substr (md5 ($ tex), 0, 8 )){
// Integrity verification failed
Return false;
}
}
$ Key_ B = $ type = "decode "? Substr ($ tex, 0, 6): $ chrArr [rand () % 62]. $ chrArr [rand () % 62]. $ chrArr [rand () % 62]. $ chrArr [rand () % 62]. $ chrArr [rand () % 62]. $ chrArr [rand () % 62];
$ Rand_key = $ key_ B. $ key;
$ Rand_key = md5 ($ rand_key );
$ Tex = $ type = "decode "? Base64_decode (substr ($ tex, 6): $ tex;
$ Texlen = strlen ($ tex );
$ Reslutstr = "";
For ($ I = 0; $ I <$ texlen; $ I ++ ){
$ Reslutstr. = $ tex {$ I} ^ $ rand_key {$ I % 32 };
}
If ($ type! = "Decode "){
$ Reslutstr = trim ($ key_ B .base64_encode ($ reslutstr), "= ");
$ Reslutstr = substr (md5 ($ reslutstr), 0, 8). $ reslutstr;
}
Return $ reslutstr;
}
$ Psa = encode_pass ("phpcode", "taintainxousad ");
Echo $ psa;
Echo encode_pass ($ psa, "taintainxousad", 'decode ');
The http://www.bkjia.com/PHPjc/327689.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/327689.htmlTechArticle code is as follows: function encode_pass ($ tex, $ key, $ type = "encode") {$ chrArr = array ('A', 'B', 'C ', 'D', 'e', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M ', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'u', 'V ', 'W '...