Current section

Files

Jump to
apollo18 lib apollo18 based64 based64_cipher.ex
Raw

lib/apollo18/based64/based64_cipher.ex

defmodule Apollo18.Based64Cipher do
@moduledoc """
Provides cipher mechanism to make your things be like Apollo 18:
Officially don't exists, only the owner know that it (if ?) exists.
The truth is out there (Maybe ...).
Uses the ```Apollo18.Cipher``` mechanism, applying additional steps,
to encode/decode to/from base64 before/after cipher/decipher.
"""
alias Apollo18.Cipher
@doc """
Same doc as for ```Apollo18.Cipher```. Only add a base64 encode conversion
to received text/string before call Apollo18.Cipher.cipher(string,salt).
"""
@doc since: "1.0.0"
def cipher(string,salt \\ 1,key \\ 0) do
string
|> Base.encode64()
|> Cipher.cipher(salt,key)
end
@doc """
Same doc as for ```Apollo18.Cipher```. Only add a base64 decode conversion
to received text/string after receive the result of call Apollo18.Cipher.decipher(string,salt).
"""
@doc since: "1.0.0"
def decipher(string,salt \\ 1,key \\ 0) do
Cipher.decipher(string,salt,key)
|> Base.decode64()
|> Tuple.to_list()
|> Enum.at(1)
end
end