PHP5 download PHP5 digital string plus decryption code

Source: Internet
Author: User
/* ----------------------------------------------------------------------------
* Script Name:encrypt.php
* Creation date:2008-4-7 10:36
* Last modified:2008-4-12 16:00
* Author:meyu
* Copyright (c) 2007
* Purpose: Digital string simple plus decryption
* ----------------------------------------------------------------------------*/
Class Encryption {
/**
* The final ciphertext code, can be set to any non-repetition of the 10-bit English characters a-za-z
*/
Private $replacement = ' urskydmeiv ';
/**
* Added ciphertext first bit, can be set to 1 bits except 0 integer, that is, 1-9
*/
Private $prefix = "8";
/**
* Public key, positive integer less than 8 bits in length
*/
Private $match = "111111";
/**
* Post-conversion control array
*/
Private $replaceenc;
Private $replacedec;
function __construct () {
for ($i =0; $i < $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;
}
}
?>

The above describes the PHP5 download PHP5 digital string encryption and decryption code, including the content of the PHP5 download, I hope to be interested in PHP tutorial friends helpful.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.