MD5/Implementation: Difference between revisions
Content added Content deleted
m (→{{header|Clojure}}: use incorrect not improve) |
|||
Line 386: | Line 386: | ||
</lang> |
</lang> |
||
{{omit from|Clojure|Unavailable bit operations}} |
|||
{{incorrect|Clojure|The example doesn't meet the requirement for MD5/Implementation. If it can't be improved it should be removed.}} |
|||
Clojure can't do this directly because it lacks some of the necessary bit-shift operators. However, it can directly use the Java implementation. |
|||
<lang Clojure>(import 'MD5) |
|||
(defn compute-MD5 [s] |
|||
(->> (.getBytes s) |
|||
MD5/computeMD5 |
|||
MD5/toHexString)) |
|||
user> (->> ["" "a" "abc" "message digest" "abcdefghijklmnopqrstuvwxyz" |
|||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" |
|||
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"] |
|||
(map (juxt compute-MD5 identity) ,) |
|||
vec) |
|||
[["D41D8CD98F00B204E9800998ECF8427E" ""] |
|||
["0CC175B9C0F1B6A831C399E269772661" "a"] |
|||
["900150983CD24FB0D6963F7D28E17F72" "abc"] |
|||
["F96B697D7CB7938D525A2F31AAF161D0" "message digest"] |
|||
["C3FCD3D76192E4007DFB496CCA67E13B" "abcdefghijklmnopqrstuvwxyz"] |
|||
["D174AB98D277D9F5A5611C2C9F419D9F" "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"] |
|||
["57EDF4A22BE3C955AC49DA2E2107B67A" "12345678901234567890123456789012345678901234567890123456789012345678901234567890"]]</lang> |
|||
=={{header|D}}== |
=={{header|D}}== |