diff options
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/dependency.lux | 4 | ||||
-rw-r--r-- | stdlib/source/program/aedifex/hash.lux | 27 |
2 files changed, 30 insertions, 1 deletions
diff --git a/stdlib/source/program/aedifex/dependency.lux b/stdlib/source/program/aedifex/dependency.lux index 13e30028b..473d5498e 100644 --- a/stdlib/source/program/aedifex/dependency.lux +++ b/stdlib/source/program/aedifex/dependency.lux @@ -1,5 +1,7 @@ (.module: - [lux (#- Type)]) + [lux (#- Type)] + ["." // #_ + ["#." hash]]) ## https://maven.apache.org/ref/3.6.3/maven-core/artifact-handlers.html (type: #export Type diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux new file mode 100644 index 000000000..bd4396006 --- /dev/null +++ b/stdlib/source/program/aedifex/hash.lux @@ -0,0 +1,27 @@ +(.module: + [lux #* + ["." host (#+ import:)] + [data + ["." binary (#+ Binary)]]]) + +## TODO: Replace with pure-Lux implementations of these algorithms +## https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode +## https://en.wikipedia.org/wiki/MD5#Algorithm +(import: #long java/lang/String) + +(import: #long java/security/MessageDigest + (#static getInstance [java/lang/String] java/security/MessageDigest) + (digest [[byte]] [byte])) + +(type: #export Hash + Binary) + +(template [<name> <algorithm>] + [(def: #export (<name> value) + (-> Binary Hash) + (|> (java/security/MessageDigest::getInstance [<algorithm>]) + (java/security/MessageDigest::digest [value])))] + + [sha1 "SHA-1"] + [md5 "MD5"] + ) |