Moving in my cryptopals.com exercise solutions
[sandbox] / cryptopals / 01.01 / hex.erl
diff --git a/cryptopals/01.01/hex.erl b/cryptopals/01.01/hex.erl
new file mode 100644 (file)
index 0000000..d778f15
--- /dev/null
@@ -0,0 +1,7 @@
+-module(hex).
+-export([decode/1]).
+
+data_in_pairs([]) -> [];
+data_in_pairs([C1,C2|Tail]) -> [ [C1] ++ [C2] | data_in_pairs(Tail) ].
+
+decode(Data) -> << <<(list_to_integer(C,16)):8>> || C <- data_in_pairs(Data) >>.