Skip to content

Instantly share code, notes, and snippets.

@aschiavon91
Last active November 16, 2020 03:39
Show Gist options
  • Select an option

  • Save aschiavon91/28d866411f2274a9fbe46f7d327cb3e4 to your computer and use it in GitHub Desktop.

Select an option

Save aschiavon91/28d866411f2274a9fbe46f7d327cb3e4 to your computer and use it in GitHub Desktop.
decode cloudflare protected email in Elixir
defmodule MyDecoder do
use Bitwise
def decode_email(encoded) do
r =
encoded
|> String.slice(0..1)
|> Integer.parse(16)
|> elem(0)
:lists.seq(2, String.length(encoded) - 2, 2)
|> Enum.map(fn n ->
encoded
|> String.slice(n..(n + 1))
|> Integer.parse(16)
|> elem(0)
|> bxor(r)
end)
|> List.to_string()
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment