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="">
?