Home  >  Article  >  php教程  >  md5 16-bit binary and 32-bit string conversion.

md5 16-bit binary and 32-bit string conversion.

WBOY
WBOYOriginal
2016-08-04 08:54:461568browse

Passwords are often saved in md5, and are often in 16-bit binary format md5. md5($str,true) in php can be easily obtained. More often than not, the md5 result is a set of 32 characters. String. I encountered this problem and searched it with a search engine. The search results were various. In fact, the conversion is very simple. I hope it will be helpful to everyone. If it is useful, remember to bookmark it

Passwords are often saved using md5, and are often in 16-bit binary format md5, which can be easily obtained using md5($str, true) in
php. More often than not, the md5 result is a set of 32 characters. String.
I encountered this problem and searched it with a search engine. The search results were varied. In fact, the conversion is very simple. I hope it will be helpful to everyone. If it is useful, remember to bookmark it. d648d7d84be222d28bc97c69767ed12f
<?php

$str = 'test';
$cm = md5($str);
$bm = md5($str, true);

$cstr = implode(unpack('H*', $bm));
$bstr = pack('H*', $cm);


echo 'str:'. $str . "<br >\n";
echo 'cm :' . $cm . "<br >\n";
echo 'cstr:' . $cstr . "<br >\n";
echo 'urlencode(bm)  :' . urlencode($bm) . "<br >\n";
echo 'urlencode(bstr):' . urlencode($bstr) . "<br >\n";
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn