-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathGenerateMd5.php
24 lines (18 loc) · 908 Bytes
/
GenerateMd5.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?php
function calculateMd5($input) {
return hash('md5', $input, true);
}
function bytesToHex($input) {
return bin2hex($input);
}
echo 'Generate a MD5 hash' . PHP_EOL;
echo PHP_EOL . '# # # SECURITY WARNING: This code is provided for achieve # # #' . PHP_EOL;
echo '# # # compatibility between different programming languages. # # #' . PHP_EOL;
echo '# # # It is NOT SECURE - DO NOT USE THIS CODE ANY LONGER ! # # #' . PHP_EOL;
echo '# # # The hash algorithm MD5 is BROKEN. # # #' . PHP_EOL;
echo '# # # DO NOT USE THIS CODE IN PRODUCTION # # #' . PHP_EOL . PHP_EOL;
$plaintext = "The quick brown fox jumps over the lazy dog";
echo 'plaintext: ' . $plaintext . PHP_EOL;
$md5Value = calculateMd5($plaintext);
echo 'md5Value (hex) length: ' . strlen($md5Value) . " data: " . bytesToHex($md5Value) . PHP_EOL;
?>