Skip to content

Instantly share code, notes, and snippets.

@mightybyte
Created September 14, 2019 19:58
Show Gist options
  • Save mightybyte/d87bda21f9fbd7d15dbda11a3074c754 to your computer and use it in GitHub Desktop.
Save mightybyte/d87bda21f9fbd7d15dbda11a3074c754 to your computer and use it in GitHub Desktop.
Playing around with hashing
(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