Last active
November 16, 2020 03:39
-
-
Save aschiavon91/28d866411f2274a9fbe46f7d327cb3e4 to your computer and use it in GitHub Desktop.
decode cloudflare protected email in Elixir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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