diff options
author | Eduardo Julian | 2020-08-26 23:04:27 -0400 |
---|---|---|
committer | Eduardo Julian | 2020-08-26 23:04:27 -0400 |
commit | c8f9f42a258f1f2f961c7f8c5571cce843e97a0a (patch) | |
tree | 887cb4d557b149826c6c9e59ea821942045b08d4 /stdlib/source/program/aedifex/hash.lux | |
parent | d77ce19bf01a009cf5255e0a5d8201d8cc2f2178 (diff) |
Download and catch dependencies in Aedifex.
Diffstat (limited to '')
-rw-r--r-- | stdlib/source/program/aedifex/hash.lux | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/stdlib/source/program/aedifex/hash.lux b/stdlib/source/program/aedifex/hash.lux index bd4396006..63511a74d 100644 --- a/stdlib/source/program/aedifex/hash.lux +++ b/stdlib/source/program/aedifex/hash.lux @@ -2,7 +2,11 @@ [lux #* ["." host (#+ import:)] [data - ["." binary (#+ Binary)]]]) + ["." binary (#+ Binary)] + ["." text + ["%" format (#+ format)]] + [number + ["." nat]]]]) ## TODO: Replace with pure-Lux implementations of these algorithms ## https://en.wikipedia.org/wiki/SHA-1#SHA-1_pseudocode @@ -25,3 +29,13 @@ [sha1 "SHA-1"] [md5 "MD5"] ) + +(def: #export representation + (-> Hash Text) + (binary.fold (function (_ byte representation) + (let [hex (:: nat.hex encode byte) + hex (case (text.size hex) + 1 (format "0" hex) + _ hex)] + (format representation hex))) + "")) |