Rot13 in Elixir

Published on 16 June 2026 (Updated: 16 June 2026)

Welcome to the Rot13 in Elixir page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

defmodule Rot13 do
  @doc """
  Returns a string after applying the Rot-13 cypher
  """
  @spec rot13(str :: String.t()) :: String.t()
  def rot13(str), do: to_charlist(str) |> Enum.map(&rot/1) |> to_string()

  defp rot(char) when char in ?a..?z, do: rem(char - ?a + 13, 26) + ?a
  defp rot(char) when char in ?A..?Z, do: rem(char - ?A + 13, 26) + ?A
  defp rot(char), do: char
end

case System.argv() do
  [str] when byte_size(str) > 0 -> Rot13.rot13(str) |> IO.puts()
  _ -> IO.puts("Usage: please provide a string to encrypt")
end

Rot13 in Elixir was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.