About PHP MD5 16-bit raw binary output with 32-bit string output

Source: Internet
Author: User
About PHP MD5 16-bit raw binary output and 32-bit string output

Because PHP AES is required to encrypt data, consider using PHP MD5 to output 16-bit binary as the key.

Google a bit "php MD5 16"? I found a lot of articles that are suggested to be implemented by intercepting strings, and the statements are as follows:

?

Perhaps they need a random string of 16 bits in length, and more likely they understand the true meaning of MD5.

?

ERLANG:MD5 ("AAA"). Percent output:<<71,188,229,199,79,88,159,72,103,219,213,126,156,169,248,8>>

From the above statement can be seen, ERLANG:MD5 output a 16-bit binary data, each bit for the 8bit,16*8 total 128bits.

That is, the MD5 output is a set of 16-bit (16Byte) 128bits of data.

?

PHP:MD5 ("AAA")//output: 47bce5c74f589f4867dbd57e9ca9f808

?

The MD5 binary format and HEX String?format tables are as follows:

Binary 71 188 229 199 79 88 159 72 103 219 213 126 156 169 248 8
16 Binary notation: 47 Bc E5 C7 4f 58 9f 48 67 Db D5 7e 9c A9 F8 08

71 If the hexadecimal representation is 47; 1886 binary is BC, and so on.

?

Now let's look at Php's MD5 function:

?

PHP:MD5 ("AAA") output 32-bit length string: 08, BC, E5, C7, 4f,, 9f, A9,, DB, D5, 7e, 9c, F8

In fact, the equivalent of 16byte binary data with hex. Similar to color rgb (255,255,255) = #FF ff ff.

?

PHP:MD5 ("AAA", ture) outputs 16byte binary data. Binary data parsing is as follows:?

?

$bin = MD5 ("AAA", ture); for ($a =0; $a
 
  < pre="">
  

?

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.