aboutsummaryrefslogtreecommitdiff
path: root/stdlib/source/program
diff options
context:
space:
mode:
authorEduardo Julian2020-08-18 23:44:12 -0400
committerEduardo Julian2020-08-18 23:44:12 -0400
commitd77ce19bf01a009cf5255e0a5d8201d8cc2f2178 (patch)
treec38b8a2962a4eb6e980078b0ac21627b0acad28c /stdlib/source/program
parentc9e452617dc14dfe9955dc556640bc07f319224a (diff)
Calculate SHA-1 and MD5 hashes.
Diffstat (limited to '')
-rw-r--r--stdlib/source/program/aedifex/dependency.lux4
-rw-r--r--stdlib/source/program/aedifex/hash.lux27
-rw-r--r--stdlib/source/program/compositor.lux1
3 files changed, 30 insertions, 2 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"]
+ )
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!"))))