SoFunction
Updated on 2025-03-10

Simple instance method for md5 encryption in php

You can directly use the md5() function to encrypt the content, such as:md5($admin_pw)

Divide this ciphertext into several segments, perform an MD5 operation on each segment, then connect the ciphertext into an ultra-long string, and finally perform an MD5 operation to obtain a ciphertext that is still a 32-bit length.

<?php

//Split the ciphertext into two segments, each segment with 16 characters
function md5_2_1($data)

{

//Encrypt the password into a ciphertext with a length of 32 characters
$data = md5($data);

//Split the password into two segments
$left = substr($data, 0, 16);

$right = substr($data, 16, 16);

//Encrypt and merge
$data = md5($left).md5($right);

// Finally, the long string is encrypted again and becomes 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);

//Cyclically intercept each character in the ciphertext and encrypt and connect
for ($i = 0; $i < 32; $i++) {

$data .= md5($data{$i});

}

//At this time, $data is 1024 characters long, and another MD5 operation is performed
return md5($data);

}

?>

The above is the detailed content of how to encrypt MD5 in PHP. For more content, please refer to the relevant articles below. Thank you for your support.