I am trying to create a simple app for creating Identicons.
Hash.input
should return first 3 values from a list, but it breaks when I try to hash 'hello'
. What is going on and how can I fix it?
defmodule Hash do
def input(input) do
hex = :crypto.hash(:md5, input) |> IO.inspect |> :binary.bin_to_list
[first, second, third | _tail] = hex
[first, second, third]
end
end
Code output:
iex(1)> Hash.input('hello')
<<93, 65, 64, 42, 188, 75, 42, 118, 185, 113, 157, 145, 16, 23, 197, 146>>
']A@'
iex(2)> Hash.input('good day')
<<202, 151, 104, 189, 8, 195, 115, 102, 95, 188, 200, 128, 33, 240, 136, 182>>
[202, 151, 104]