Copy CodeThe code is as follows:
// +----------------------------------------------------------------------+
// | Willko Framework |
// +----------------------------------------------------------------------+
// | Copyright (c) 2008-2009 Willko Cheng |
// +----------------------------------------------------------------------+
// | Authors:willko Cheng |
// +----------------------------------------------------------------------+
$string Clear Text or redaction
$isEncrypt is encrypted
$key key
Use SHA1 to generate a key book with more than 300 characters using zlib compression
function Dencrypt ($string, $isEncrypt = true, $key = Key_space) {
if (!isset ($string {0}) | |!isset ($key {0})) {
return false;
}
$dynKey = $isEncrypt? Hash (' SHA1 ', Microtime (True)): substr ($string, 0, 40);
$fixedKey = hash (' SHA1 ', $key);
$dynKeyPart 1 = substr ($dynKey, 0, 20);
$dynKeyPart 2 = substr ($dynKey, 20);
$fixedKeyPart 1 = substr ($fixedKey, 0, 20);
$fixedKeyPart 2 = substr ($fixedKey, 20);
$key = hash (' SHA1 ', $dynKeyPart 1. $fixedKeyPart 1. $dynKeyPart 2. $fixedKeyPart 2);
$string = $isEncrypt? $fixedKeyPart 1. $string. $dynKeyPart 2: (Isset ($string {339})? Gzuncompress (Base64_decode (substr ($string,)): Base64_decode (substr ($string , 40)));
$n = 0;
$result = ";
$len = strlen ($string);
for ($n = 0; $n < $len; $n + +) {
$result. = Chr (Ord ($string {$n}) ^ ord ($key {$n% 40}));
}
Return $isEncrypt? $dynKey. Str_replace (' = ', ' ', Base64_encode ($n > 299? gzcompress ($result): $result)): substr ($result, 20,-20);
}
http://www.bkjia.com/PHPjc/319806.html www.bkjia.com true http://www.bkjia.com/PHPjc/319806.html techarticle Copy the code as follows://+----------------------------------------------------------------------+//| Willko Framework | // +-------------------------------------------------...