Created
September 14, 2019 19:58
-
-
Save mightybyte/d87bda21f9fbd7d15dbda11a3074c754 to your computer and use it in GitHub Desktop.
Playing around with hashing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(module hash MODULE_ADMIN | |
"A smart contract to greet the world." | |
(defcap MODULE_ADMIN () true) | |
(defun revcat (a b) | |
(+ b a) | |
) | |
(defun phash:string (str:string) | |
(let* ((h (hash str)) | |
(hint (str-to-int 64 h)) | |
(hhex (int-to-str 16 hint)) | |
(numpad (- 64 (length hhex))) | |
(padded (fold (revcat) hhex (make-list numpad "0"))) | |
) | |
padded)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment