rotn v0.2.0 Rotn View Source
Rotn takes a compatible binary and an integer value and rotates the corresponding characters of the binary by the integer value around a circle of ASCII values from 32 - 126 inclusive.
Link to this section Summary
Functions
Returns an {:ok, "decoded string"}
tuple
Returns an decoded string, raising an ArgumentError if the provided text cannot be decoded or the shift value is invalid
Returns an {:ok, "encoded string"}
tuple
Returns an encoded string, raising an ArgumentError if the provided text cannot be encoded or the shift value is invalid
Link to this section Functions
decode(text, delta) View Source
Returns an {:ok, "decoded string"}
tuple.
Examples
iex> Rotn.decode("V-z$\"#-{|#-srn!", 13)
{:ok, "I must not fear"}
iex> Rotn.decode(68.9, 13)
{:error, "Cannot decode non-binary"}
iex> Rotn.decode("/# 92z/ -9{ '*)\".9/*9/# 9/-${ ", 2.5)
{:error, "Incompatible shift value"}
iex> Rotn.decode("Zyu(4})4*|y4#}$x!}\"\"y(", -20)
{:ok, "Fear is the mindkiller"}
decode!(text, delta) View Source
Returns an decoded string, raising an ArgumentError if the provided text cannot be decoded or the shift value is invalid.
Examples
iex> Rotn.decode!("V-z$\"#-{|#-srn!", 13)
"I must not fear"
iex> Rotn.decode!(68.9, 13)
** (ArgumentError) Cannot decode non-binary
iex> Rotn.decode!("/# 92z/ -9{ '*)\".9/*9/# 9/-${ ", 2.5)
** (ArgumentError) Incompatible shift value
encode(text, delta) View Source
Returns an {:ok, "encoded string"}
tuple.
Examples
iex> Rotn.encode("I must not fear", 13)
{:ok, "V-z$\"#-{|#-srn!"}
iex> Rotn.encode(68.9, 13)
{:error, "Cannot encode non-binary"}
iex> Rotn.encode("the water belongs to the tribe", 2.5)
{:error, "Incompatible shift value"}
iex> Rotn.encode("Fear is the mindkiller", -20)
{:ok, "Zyu(4})4*|y4#}$x!}\"\"y("}
encode!(text, delta) View Source
Returns an encoded string, raising an ArgumentError if the provided text cannot be encoded or the shift value is invalid.
Examples
iex> Rotn.encode!("I must not fear", 13)
"V-z$\"#-{|#-srn!"
iex> Rotn.encode!(68.9, 13)
** (ArgumentError) Cannot encode non-binary
iex> Rotn.encode!("the water belongs to the tribe", 2.5)
** (ArgumentError) Incompatible shift value