-
- //Iterative algorithm
- function md5_1_1($data, $times = 32)
- {
- //Loop using MD5
- for ($i = 0; $i < $times; $ i++) {
- $data = md5($data);
- }
- return $data;
- }
- //Recursive algorithm
- function md5_1_2($data, $times = 32)
- {
- if ($times > 0) {
- $data = md5($data);
- $times--;
- return md5_1_2($data, $times); //implement recursion
- } else {
- return $data;
- }
- }
- ?>
Copy code
Transformation 2: Cryptotext split MD5
-
- //Split the ciphertext into two sections, each section has 16 characters
- function md5_2_1($data)
- {
- //First encrypt the password into a 32-character password Text
- $data = md5($data);
- //Split the password into two sections
- $left = substr($data, 0, 16);
- $right = substr($data, 16, 16);
- / /Encrypt separately and then merge
- $data = md5($left).md5($right);
- //Finally, encrypt the long string again to become a 32-character ciphertext
- return md5($data);
- }
- //Split the ciphertext into 32 segments, each segment has 1 character
- function md5_2_2($data)
- {
- $data = md5($data);
- //Loop to intercept each character in the ciphertext and encrypt it, Connect
- for ($i = 0; $i < 32; $i++) {
- $data .= md5($data{$i});
- }
- //At this time, the length of $data is 1024 characters, and then Perform an MD5 operation
- return md5($data);
- }
- ?>
-
Copy code
Transformation three: Additional string interference
-
- //Additional string at the end of the original data
- function md5_3_1($data, $append)
- {
- return md5($data.$append);
- }
- //Additional characters String at the head of the original data
- function md5_3_2($data, $append)
- {
- return md5($append.$data);
- }
- //Additional string at the head and tail of the original data
- function md5_3_3($data, $ append)
- {
- return md5($append.$data.$append);
- }
- ?>
Copy code
Transformation four: Case transformation interference
Since the English letters in the ciphertext returned by the md5() function provided by PHP are all lowercase, we can convert them all to uppercase and then perform an MD5 operation.
-
- function md5_4($data)
- {
- //Get the ciphertext of the password first
- $data = md5($data);
- //Then convert all the English letters in the ciphertext For uppercase
- $data = strtotime($data);
- //Finally perform another MD5 operation and return
- return md5($data);
- }
- ?>
Copy code
Transformation five: Character String order interference
After reversing the order of the ciphertext string after the MD5 operation, perform the MD5 operation again.
-
- function md5_5($data)
- {
- //Get the ciphertext of the data
- $data = md5($data);
- //Reverse the character order of the ciphertext string
- $data = strrev($data);
- //Finally perform another MD5 operation and return
- return md5($data);
- }
- ?>
-
Copy code
Use php md5() function, more efforts can be made in encrypting user information to reduce more security risks.
|