MD5/Implementation: Difference between revisions

Line 1,177:
private static int INIT_D = 0x10325476;
private static int[] SHIFT_AMTS = new int[] {
7, 12, 17, 22,
5, 9, 14, 20,
Line 1,286:
{
StringBuilder sb = new StringBuilder();
String HEX_CHARS = "0123456789ABCDEF";
for (int i = 0; i < b.length; i++)
{
int n = sb.append(int)String.format("%02X", b[i] & 0xFF));
sb.append(HEX_CHARS.charAt(n >>> 4)).append(HEX_CHARS.charAt(n & 0x0F));
}
return sb.toString();
Line 1,297 ⟶ 1,295:
public static void main(String[] args)
{
String[] testStrings = new String[] { "", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "12345678901234567890123456789012345678901234567890123456789012345678901234567890" };
for (String s : testStrings)
System.out.println("0x" + toHexString(computeMD5(s.getBytes())) + " <== \"" + s + "\"");
Line 1,315 ⟶ 1,313:
0x57EDF4A22BE3C955AC49DA2E2107B67A <== "12345678901234567890123456789012345678901234567890123456789012345678901234567890"
</pre>
 
 
=={{header|Modula-3}}==
Anonymous user