Skip to content

Instantly share code, notes, and snippets.

@bjhaid
Created July 18, 2015 00:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjhaid/175c7ac4601a4beb8fb5 to your computer and use it in GitHub Desktop.
Save bjhaid/175c7ac4601a4beb8fb5 to your computer and use it in GitHub Desktop.
Vigenère Cipher (Hex XOR Variant)
VigenereHexXOR = fun(Plain, KeyList) -> G = fun([H|T], [B|R], Q, List, F) ->
F(T, R, Q, [H bxor list_to_integer(B, 16)|List], F);
(Act, [], Q, List, F) ->
F(Act, Q, Q, List, F);
([], _, _, List, _) -> [integer_to_list(X, 16) || X <- lists:reverse(List)]
end,
G(Plain, KeyList, KeyList, [], G)
end.
VigenereHexXOR("cool!", ["01", "3F"]).
["62","50","6E","53","20"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment