Current section
Files
Jump to
Current section
Files
lib/utils.ex
defmodule Utils do
def to_bin(string) do
string |> Base.decode16()
end
def to_hex(binary) do
binary |> Base.encode16() |> String.downcase()
end
def reverse(binary) do
binary |> :binary.bin_to_list() |> Enum.reverse() |> :binary.list_to_bin()
end
def sha256(binary) do
:crypto.hash(:sha256, binary)
end
def hash(binary) do
binary |> sha256 |> sha256 |> reverse
end
end