From d77ce19bf01a009cf5255e0a5d8201d8cc2f2178 Mon Sep 17 00:00:00 2001 From: Eduardo Julian Date: Tue, 18 Aug 2020 23:44:12 -0400 Subject: Calculate SHA-1 and MD5 hashes. --- stdlib/source/program/aedifex/dependency.lux | 4 +++- stdlib/source/program/aedifex/hash.lux | 27 +++++++++++++++++++++++++++ stdlib/source/program/compositor.lux | 1 - 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 stdlib/source/program/aedifex/hash.lux (limited to 'stdlib/source/program') 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 [ ] + [(def: #export ( value) + (-> Binary Hash) + (|> (java/security/MessageDigest::getInstance []) + (java/security/MessageDigest::digest [value])))] + + [sha1 "SHA-1"] + [md5 "MD5"] + ) diff --git a/stdlib/source/program/compositor.lux b/stdlib/source/program/compositor.lux index d551f61f2..1b17a4de8 100644 --- a/stdlib/source/program/compositor.lux +++ b/stdlib/source/program/compositor.lux @@ -149,7 +149,6 @@ (<| (or-crash! "Export failed:") (do (try.with promise.monad) [_ (/export.export (get@ #platform.&file-system platform) - (get@ #/static.host-module-extension static) export)] (wrap (log! "Export complete!")))) -- cgit v1.2.3