%SYSTEM.Encryption MD5Hash function -return value conversion
Hi,
We wanted to use the MD5Hash function,
And had trouble understanding it's return value , as documented:
"Return value: 16-byte MD5 hash."
The value we wanted should have been a simple string, and we did not know how to convert the output to string.
Searching for a solution we found this article:
https://groups.google.com/forum/#!msg/intersystems-public-cache/FdkHIgS9PkQ/P7s-92kN70UJ
That had this solution that works:
"If you know what this gibberish stuff is about, it can be very simple ;)
USER> s h = ##class(%SYSTEM.Encryption).
USER> s h0x = ""
USER> f i=1:1:$l(h) {s chr = $zhex($ascii($e(h,i))) s h0x = h0x _
$s($l(chr) = 1: "0"_chr, 1:chr)}
USER> w $zcvt(h0x,"l")
1d2fd35d57d574b807a807b507528b
And also a simpler solution:
" s pwd="12345678"
s md5=$system.Encryption.
s md5hex=##class(%xsd.hexBinary)
w md5hex,! "
Is this issue addressed in Cache documentation? and is there a more standard way to get the string result?
Regards,
Nael