Encrypted decryption function and DES encryption and decryption instance in PHP, Phpdes encryption and decryption instance
In this paper, the application of cryptographic decryption function and DES encryption and decryption in PHP is described, and it is shared for everyone's reference. Specific as follows:
Examples, examples of PHP encryption and decryption
Cryptographic functions:
Copy the Code Code as follows:/** Function: Encrypt string processing* Parameter one: Content that needs to be e
Encrypted decryption function in PHP and DES encryption and decryption instance
Examples, examples of PHP encryption and decryption
Cryptographic functions:
The code is as follows:/*
* Function: Encrypt string processing
* Parameter one: Content that needs to be encrypted
* Parameter two: key
*/
function Passport_encrypt ($STR, $key) {//encryption function
Srand (Double) microtime () * 1000000);
$encrypt _key=md5 (rand (0, 32000));
$ctr = 0;
$tmp =
The following code is saved as a MD5Crypt.class.php file
The code is as follows
Copy Code
Class Md5crypt {/*** Enter description here ...* @param unknown_type $str* @return String*/Public final static function Mdsha ($STR) {$code = substr (MD5 ($STR), 10);$code. = substr (SHA1 ($STR), 0, 28);$code. = substr (MD5 ($STR), 0, 22);$code. = substr (SHA1 ($STR), 16). MD5 ($STR);Return Self::chktoken ()? $code: null;}/*** Enter description here ...* @param unknown_type $para
It was because of the use of Base64 that the problem occurred when the token was sent through the Get method.
For example: http://test/test.php?a=1+2
You use $_get["a" to obtain is: 1 2, namely that the plus sign is gone. At first I used UrlEncode to convert it, but there were always one or two results that were unexpected.
Later think of Base64 characters are limited to: [a-za-z0-9\+\/=] So many, plus the problem, I will replace the plus sign without problems, underline is the best choice. Her
This article describes the encryption and decryption function in PHP and DES encryption and decryption application, share for everyone to reference. Specifically as follows:
Examples, examples of PHP encryption decryption
Cryptographic functions:
Copy Code code as follows:
/*
* Function: Encrypt string to handle
* Parameter one: Content that needs to be encrypted
* Parameter two: key
*/
function Passport_encrypt ($STR, $key) {//cryptographic functions
Srand (Double)
session_id, You can judge this submission as an external submission.
How do I match an action to be performed?
In the token, to the token of the action name into this token, so, in processing, the action to solve the comparison on the line.
The Gtoken I wrote earlier could not reach the second one mentioned above, and I modified it today to add the function 2. Personal feeling is OK.
Please see the code, feel where there is unreasonable place, please enlighten me! Thank you.
Encryption I w
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.