Last active
March 26, 2018 14:30
-
-
Save danj3/a4fd7dc390bb2fac59495140905a53ad to your computer and use it in GitHub Desktop.
Elixir: create an armored sha256 hash of an input
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
defmodule HashSignature do | |
@doc """ | |
encode input to a sha256 and output as an armored string. | |
results should be fully portable and consistent with other | |
tools. | |
""" | |
def get( input ) do | |
:crypto.hash( :sha256, input ) | |
|> :crypto.bytes_to_integer | |
|> (fn i -> :io_lib.format("~64.16.0b",[i]) |> hd end ).() | |
|> to_string | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment