Message Digest - MD5 Algorithm
Part:
1
2
3
4
5
(Continued from previous part...)
If you run this sample program with JDK 1.5, you should get the following output:
Message digest object info:
Algorithm = MD5
Provider = SUN version 1.5
toString = MD5 Message Digest from SUN, <initialized>
MD5("") =
D41D8CD98F00B204E9800998ECF8427E
MD5("abc") =
900150983CD24FB0D6963F7D28E17F72
MD5("abcdefghijklmnopqrstuvwxyz") =
C3FCD3D76192E4007DFB496CCA67E13B
The output matches the testing result listed in RFC 1321.
MD5 Implementation in PHP
If you are interested in using MD5 in PHP, you can use the built-in function md5().
Here is a sample program showing you how to use md5() function:
<?php # PhpMd5Test.php
# Copyright (c) 2006 by Dr. Herong Yang, http://www.herongyang.com/
#
$input = "";
$output = md5($input);
print("\n");
print("MD5(\"".$input."\") =\n");
print(" $output\n");
$input = "abc";
$output = md5($input);
print("\n");
print("MD5(\"".$input."\") =\n");
print(" $output\n");
$input = "abcdefghijklmnopqrstuvwxyz";
$output = md5($input);
print("\n");
print("MD5(\"".$input."\") =\n");
print(" $output\n");
?>
If you run this sample program with PHP 5, you should get:
MD5("") =
d41d8cd98f00b204e9800998ecf8427e
MD5("abc") =
900150983cd24fb0d6963f7d28e17f72
MD5("abcdefghijklmnopqrstuvwxyz") =
c3fcd3d76192e4007dfb496cca67e13b
(Continued on next part...)
Part:
1
2
3
4
5
|