Sha256: 5e20db2825185ae286c15b7507c8e90b9cfca70c53e593278c21c00e18d079ee

Contents?: true

Size: 1.59 KB

Versions: 69

Compression:

Stored size: 1.59 KB

Contents

defmodule SimpleCipher do
  @doc """
  Given a `plaintext` and `key`, encode each character of the `plaintext` by
  shifting it by the corresponding letter in the alphabet shifted by the number
  of letters represented by the `key` character, repeating the `key` if it is
  shorter than the `plaintext`.

  For example, for the letter 'd', the alphabet is rotated to become:

  defghijklmnopqrstuvwxyzabc

  You would encode the `plaintext` by taking the current letter and mapping it
  to the letter in the same position in this rotated alphabet.

  abcdefghijklmnopqrstuvwxyz
  defghijklmnopqrstuvwxyzabc

  "a" becomes "d", "t" becomes "w", etc...

  Each letter in the `plaintext` will be encoded with the alphabet of the `key`
  character in the same position. If the `key` is shorter than the `plaintext`,
  repeat the `key`.

  Example:

  plaintext = "testing"
  key = "abc"

  The key should repeat to become the same length as the text, becoming
  "abcabca". If the key is longer than the text, only use as many letters of it
  as are necessary.
  """
  def encode(plaintext, key) do
  end

  @doc """
  Given a `ciphertext` and `key`, decode each character of the `ciphertext` by
  finding the corresponding letter in the alphabet shifted by the number of
  letters represented by the `key` character, repeating the `key` if it is
  shorter than the `ciphertext`.

  The same rules for key length and shifted alphabets apply as in `encode/2`,
  but you will go the opposite way, so "d" becomes "a", "w" becomes "t",
  etc..., depending on how much you shift the alphabet.
  """
  def decode(ciphertext, key) do
  end
end

Version data entries

69 entries across 69 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.179 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.178 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.177 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.176 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.175 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.174 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.173 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.172 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.171 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.170 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.169 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.167 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.166 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.165 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.164 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.163 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.162 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.161 tracks/elixir/exercises/simple-cipher/simple_cipher.exs
trackler-2.2.1.160 tracks/elixir/exercises/simple-cipher/simple_cipher.exs