http://blog.ddian.cn/?post=923
Class ender{
private $enkey;//Key used for encryption and decryption
The construction parameter is the key
Public function __construct ($key = ") {
if (! $key) {
$this->enkey= $key;
}
}
Set the key
Public Function Set_key ($key) {
$this->enkey= $key;
}
Private Function KeyED ($txt, $encrypt _key)
{
$encrypt _key = MD5 ($encrypt _key);
$
This article provides a detailed analysis of encryption functions written in PHP that support private keys. For more information about how to develop a PHP System, members are often an indispensable module, and password processing is a problem that must be faced. the Mcrypt encryption library of PHP requires additional settings. many people directly use md5 () function encryption: This method is indeed safe, but because md5 is irreversible and cannot be restored, there are some inconveniences. T
that this commit is an external submission.How do I match the action to be performed?In token, the action name of this token is written into this token, so that, in the process of processing, the action is solved to compare on the line.I used to write the Gtoken can not reach the above mentioned in the second, today modified a bit, the function 2 plus. Personal feeling is OK.Please look at the code, feel where there is unreasonable place, also please enlighten!Encryption I was looking for a met
that this commit is an external submission. How do I match the action to be performed?in token, the action name of this token is written into this token, so that, in the process of processing, the action is solved to compare on the line.I used to write the Gtoken can not reach the above mentioned in the second, today modified a bit, the function 2 plus. Personal feeling is OK.please look at the code, feel where there is unreasonable place, also please enlighten!encryption I was looking for a me
In the development of PHP system, the member part is often an essential module, and the password processing has to face the problem, PHP Mcrypt Encryption Library needs additional settings, many people are directly using the MD5 () function encryption, this method is indeed safe, but because MD5 is irreversible encryption, Unable to restore the password, so there are some inconveniences, this article describes the encryption function to support the private key, it is good to use.
The code is as
The php Encryption Class shared in this article is a php implementation class file that supports Chinese and English encryption and password decryption. If you need it, refer to it, but it is best to set the document encoding to UTF-8.
The following code is saved as the 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
This article describes the function for generating random encryption in php. If you need it, you can refer to it. It is a custom function that is not provided by the system.
The Code is as follows:
Copy code
Function encrypt_str ($ TXT, $ KEY){Srand (double) microtime () * 1000000 );$ ENCRYPT_KEY = md5 (rand (0, 32000 ));$ CTR = 0;$ TMP = "";$ I = 0;For (; $ I {If ($ CTR = strlen ($
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.