Fulib v0.1.2 Fulib.RSA View Source
Link to this section Summary
Functions
Decrypt message with RSA private key
iex(8)> {:ok, decrypted_clear_text} = Fulib.RSA.decrypt(cipher_text, rsa_private_key)
{:ok, "Important message"}
Encrypt message with RSA public key in base64
iex> clear_text = "Important message"
"Important message"
iex> {:ok, cipher_text} = Fulib.RSA.encrypt(clear_text, rsa_public_key)
{:ok, "Lmbv...HQ=="}
Generates RSA private/public keypair of {bits} size. Default is 4096.
iex> {:ok, {priv, pub}} = Fulib.RSA.generate_keypair("4096")
Generates RSA private key of {bits} size. Default is 4096.
iex> {:ok, priv} = Fulib.RSA.generate_private_key("4096")
Generates RSA public key
iex> {:ok, priv} = Fulib.RSA.generate_private_key
iex> {:ok, pub} = Fulib.RSA.generate_public_key(priv)
Sign message with RSA private key
iex> {:ok, signature} = Fulib.RSA.sign(message, rsa_private_key)
{:ok, <<...>>}
Verify signature with RSA public key
iex> {:ok, valid} = Fulib.RSA.verify(message, signature, rsa_public_key
{:ok, true}
Link to this section Types
Link to this type
private_key()
View Source
private_key()
View Source
private_key() :: String.t()
private_key() :: String.t()
Link to this type
public_key()
View Source
public_key()
View Source
public_key() :: String.t()
public_key() :: String.t()
Link to this section Functions
Link to this function
decrypt(cipher_msg, private_key \\ nil)
View Source
decrypt(cipher_msg, private_key \\ nil)
View Source
decrypt(String.t(), private_key()) :: {atom(), String.t()}
decrypt(String.t(), private_key()) :: {atom(), String.t()}
Decrypt message with RSA private key
iex(8)> {:ok, decrypted_clear_text} = Fulib.RSA.decrypt(cipher_text, rsa_private_key)
{:ok, "Important message"}
Link to this function
encrypt(message, public_key \\ nil)
View Source
encrypt(message, public_key \\ nil)
View Source
encrypt(String.t(), public_key()) :: {atom(), String.t()}
encrypt(String.t(), private_key()) :: {atom(), String.t()}
encrypt(String.t(), public_key()) :: {atom(), String.t()}
encrypt(String.t(), private_key()) :: {atom(), String.t()}
Encrypt message with RSA public key in base64
iex> clear_text = "Important message"
"Important message"
iex> {:ok, cipher_text} = Fulib.RSA.encrypt(clear_text, rsa_public_key)
{:ok, "Lmbv...HQ=="}
Link to this function
generate_keypair(bits \\ "4096") View Source
Generates RSA private/public keypair of {bits} size. Default is 4096.
iex> {:ok, {priv, pub}} = Fulib.RSA.generate_keypair("4096")
Link to this function
generate_private_key(bits \\ "4096") View Source
Generates RSA private key of {bits} size. Default is 4096.
iex> {:ok, priv} = Fulib.RSA.generate_private_key("4096")
Link to this function
generate_public_key(private_key)
View Source
generate_public_key(private_key)
View Source
generate_public_key(private_key()) :: {atom(), public_key()}
generate_public_key(private_key()) :: {atom(), public_key()}
Generates RSA public key
iex> {:ok, priv} = Fulib.RSA.generate_private_key
iex> {:ok, pub} = Fulib.RSA.generate_public_key(priv)
Link to this function
private_encrypt(message, private_key \\ nil) View Source
Link to this function
public_decrypt(cipher_msg, public_key \\ nil)
View Source
public_decrypt(cipher_msg, public_key \\ nil)
View Source
public_decrypt(String.t(), public_key()) :: {atom(), String.t()}
public_decrypt(String.t(), public_key()) :: {atom(), String.t()}
Link to this function
sign(message, private_key \\ nil)
View Source
sign(message, private_key \\ nil)
View Source
sign(String.t(), private_key()) :: {atom(), binary()}
sign(String.t(), private_key()) :: {atom(), binary()}
Sign message with RSA private key
iex> {:ok, signature} = Fulib.RSA.sign(message, rsa_private_key)
{:ok, <<...>>}
Link to this function
verify(message, signature, public_key \\ nil)
View Source
verify(message, signature, public_key \\ nil)
View Source
verify(String.t(), binary(), public_key()) :: {atom(), boolean()}
verify(String.t(), binary(), public_key()) :: {atom(), boolean()}
Verify signature with RSA public key
iex> {:ok, valid} = Fulib.RSA.verify(message, signature, rsa_public_key
{:ok, true}