Skip to content

Instantly share code, notes, and snippets.

@cs-victor-nascimento
Created January 17, 2018 21:12
Show Gist options
  • Save cs-victor-nascimento/76e7086a430c06112a6f54dce90a2d51 to your computer and use it in GitHub Desktop.
Save cs-victor-nascimento/76e7086a430c06112a6f54dce90a2d51 to your computer and use it in GitHub Desktop.
An Elixir benchmarking story - base64url
defmodule :base64url do
def encode(term) when is_binary(term),
do: Base.url_encode64(term, ignore: :whitespace, padding: false)
def encode(term) when is_list(term), do: :erlang.iolist_to_binary(term) |> encode()
def decode(term) when is_binary(term),
do: Base.url_decode64!(term, ignore: :whitespace, padding: false)
def decode(term) when is_list(term), do: :erlang.iolist_to_binary(term) |> decode()
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment