Hi, Eric.
There are multiple ways to translate a binary hash or encoding to
printable characters; base 64 encoding and hex dump are two options.
%SYS>r eric
4– :«*$ åì" k
%SYS>zzdump eric
0000: 0034 2013 0020 0020 0020 003A 00AB 002A 4– :«*
0008: 0024 0020 00E5 00EC 0022 0020 006B $ åì" k
%SYS>s eric=$zcvt(eric,"O","RAW") //email had caused the
characters to be widened, high-order bytes are zeroes, so we can strip
them using RAW output translation.
%SYS>zzdump eric
0000: 34 3F 20 20 20 3A AB 2A 24 20 E5 EC 22 20 6B 4? :«*$
åì" k
%SYS>w $System.Encryption.Base64Encode(eric)
ND8gICA6qyokIOXsIiBr
%SYS>w $L($System.Encryption.Base64Encode(eric))
20
The hex dump does match the MD5 test output (corresponding to the -x --
hex option).
%SYS>r test
12345678901234567890123456789012345678901234567890123456789012345678901234567890
%SYS>s ryan2=$System.Encryption.MD5Hash(test)
%SYS>zzdump ryan2
0000: 57 ED F4 A2 2B E3 C9 55 AC 49 DA 2E 21 07 B6 7A
Wíô¢+ãÉU¬IÚ.!.¶z
%SYS>s ryan3="" for i=1:1:$length(ryan2) { s
ryan3=ryan3_$zhex($a($extract(ryan2,i))) }
%SYS>w ryan3
57EDF4A22BE3C955AC49DA2E217B67A
%SYS>
Eric wrote (10/5/09 8:46 PM):
> Hi Derek!
>
> The test suite in the standard (
http://tools.ietf.org/html/rfc1321)
> uses 32 bit hex hash:
>
> A.5 Test suite
>
> The MD5 test suite (driver option "-x") should print the following
> results:
>
> MD5 test suite:
> MD5 ("") = d41d8cd98f00b204e9800998ecf8427e
> MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661
> MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
> MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0
> MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
> MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")
> =
> d174ab98d277d9f5a5611c2c9f419d9f
> MD5
> ("123456789012345678901234567890123456789012345678901234567890123456
> 78901234567890") = 57edf4a22be3c955ac49da2e2107b67a
>
>
> and there is a very nice test page here:
http://hash-it.net/
>
> Maybe the %SYSTEM.Encryption implementation could eventually offer
> both 16& 32 bytes output?