From 78e5caa664b860189ea86f95fe68ad5e6705897b Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 25 Sep 2018 19:57:35 +0200 Subject: s/block/page, change semantics to use more binaries, fixes --- shard/lib/data/data.ex | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'shard/lib/data') diff --git a/shard/lib/data/data.ex b/shard/lib/data/data.ex index c2c659d..78c73cd 100644 --- a/shard/lib/data/data.ex +++ b/shard/lib/data/data.ex @@ -18,6 +18,18 @@ defmodule SData do :crypto.hash(algo, (:erlang.term_to_binary term)) end + def term_bin(term) do + :erlang.term_to_binary term + end + + def bin_hash(bin, algo \\ :sha256) do + :crypto.hash(algo, bin) + end + + def term_unbin(bin) do + :erlang.binary_to_term(bin, [:safe]) + end + @doc""" Compare function for arbitrary terms using the Erlang order """ -- cgit v1.2.3