defmodule Identicon do
def main(input) do
input
|> hash_input # pipe operator: input is fed into hash_input
end
def hash_input(input) do
# equal to the below the first two lines
# hash = :crypto.hash(:md5, input)
# :binary.bind_to_list(hash)
:crypto.hash(:md5, input)
|> :binary.bin_to_list
end
end
hash = :crypto.hash(:md5, "banana")
<< 114, 179, 2, ... , 65 >>
Base.encode16(hash)
"72B302BF297A228A75730123EFEF7C41" # unique sequence of string
:binary.bin_to_list(hash)
[114, 179, 2, ..., 65] # unique sequence of numbers