php Simple Example Method for md5 Encryption

  • 2021-12-21 04:33:37
  • OfStack

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

This ciphertext is divided into several segments, and each segment is operated by MD5 once, then this pile of ciphertext is connected into an ultra-long string, and finally, MD5 operation is performed once, and the ciphertext with length of 32 bits is still obtained.


// Divide the ciphertext into two segments, each of which 16 Characters 

function md5_2_1($data)


// First, encrypt the password to a growth rate of 32 Character ciphertext 

$data = md5($data);

// Divide the password into two pieces 

$left = substr($data, 0, 16);

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

// Encrypt separately and then merge 

$data = md5($left).md5($right);

// Finally, re-encrypt the long string 1 Time, become 32 Character ciphertext 

return md5($data);


// Split the ciphertext into 32 Paragraph, each paragraph 1 Characters 

function md5_2_2($data)


$data = md5($data);

// Cyclic interception of each character in the cipher text and encryption, connection 

for ($i = 0; $i < 32; $i++) {

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


// At this time $data The length is 1024 Characters, and then proceed 1 Times MD5 Operation 

return md5($data);



The above is how php md5 encryption details, more content you can refer to the relevant articles below, thank you for the support of this site.

Related articles: