PHP, suitable for posting simple encrypted ciphertext
Copy code The code is as follows:
php
//replacement encrypted replacement from the previous version
function compress_func($match) {return strlen($match[0]).$match[0]{0};}
function uncompress_func($match) {return str_repeat($match[2], $match[1]);}
function compress($str) {
$i = 0;
$pattern = array(); > return preg_replace_callback($pattern, "compress_func", $str);
}
function uncompress($str) {
return preg_replace_callback("/(d+)(w)/", " uncompress_func", $str);
}
?>
AWK, common format
Copy code The code is as follows:
#!/bin/awk
function compress(str, _ARGVEND_, str_out, str_len, i, s, l) {
str_out = "";
str_len = length(str);
s = "";
l = 1;
for(i =1; i <= str_len; i++) {
if(substr( str, i, 1) == s) l++; str_out= str_out""s; Return str_out;
}
function uncompress(str, _ARGVEND_, str_out, str_len, i, c) {
str_out = "";
str_len = length(str);
for(i =1; i <= str_len; i++) {
c = 0;
while(substr(str, i, 1)~/[0-9]/) {
c = c*10+substr(str, i, 1) ; i ++;
}
if (c & lt; 1) C = 1;
While (C--) str_out = str_out "" substr (str, i, 1);
}
return str_out;
}
http://www.bkjia.com/PHPjc/319046.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/319046.html
TechArticle
PHP, adapted to the simple encrypted ciphertext copy code of the above post, the code is as follows: ?php //replacement comes from above A version of the encrypted replacement functioncompress_func($match){returnstrlen($match[0]).$mat...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn