Alternative application of phpmd5 encryption
- // Iterative algorithm
- Function md5_1_1 ($ data, $ times = 32)
- {
- // Use MD5 repeatedly
- 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;
- }
- }
- ?>
Transformation 2:Ciphertext segmentation MD5
- // Divide the ciphertext into two segments, each of which contains 16 characters
- Function md5_2_1 ($ data)
- {
- // Encrypt the password into a 32-character ciphertext
- $ Data = md5 ($ data );
- // Split the password into two segments
- $ Left = substr ($ data, 0, 16 );
- $ Right = substr ($ data, 16, 16 );
- // Encrypt the data separately before merging.
- $ Data = md5 ($ left). md5 ($ right );
- // Finally, the long string is re-encrypted to a 32-character ciphertext.
- Return md5 ($ data );
- }
- // Divide the ciphertext into 32 segments, each of which contains 1 character
- Function md5_2_2 ($ data)
- {
- $ Data = md5 ($ data );
- // Cyclically intercept each character in the ciphertext and encrypt and connect it
- For ($ I = 0; $ I <32; $ I ++ ){
- $ Data. = md5 ($ data {$ I });
- }
- // At this time, $ data is 1024 characters in length, and an MD5 operation is performed again.
- Return md5 ($ data );
- }
- ?>
-
Transformation 3:Append string interference
- // Append the string to the end of the original data
- Function md5_3_1 ($ data, $ append)
- {
- Return md5 ($ data. $ append );
- }
- // Append the string to the header of the original data
- Function md5_3_2 ($ data, $ append)
- {
- Return md5 ($ append. $ data );
- }
- // Append the string to the beginning and end of the original data
- Function md5_3_3 ($ data, $ append)
- {
- Return md5 ($ append. $ data. $ append );
- }
- ?>
Transformation 4:Case-sensitive conversion interferenceSince all English letters in the ciphertext returned by the md5 () function provided by PHP are in lower case, we can convert all of them into upper case and then perform an MD5 operation.
- Function md5_4 ($ data)
- {
- // Obtain the ciphertext of the password first
- $ Data = md5 ($ data );
- // Convert all the English letters in the ciphertext into uppercase letters.
- $ Data = strtotime ($ data );
- // Perform the MD5 operation again and return the result
- Return md5 ($ data );
- }
- ?>
Transformation 5:String order interferenceAfter the sequence of the ciphertext string after the MD5 operation is adjusted, the MD5 operation is performed again.
- Function md5_5 ($ data)
- {
- // Obtain the ciphertext of the data
- $ Data = md5 ($ data );
- // Re-convert the character sequence of the ciphertext string
- $ Data = strrev ($ data );
- // Perform the MD5 operation again and return the result
- Return md5 ($ data );
- }
- ?>
-
Using the php md5 () function can reduce security risks by making more efforts to encrypt user information. |