Home > php教程 > php手册 > body text

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

WBOY
Release: 2016-08-04 08:54:46
Original
1593 people have browsed it

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.
<?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";
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template