View Source NostrBasics.Crypto.AES256CBC (NostrBasics v0.1.5)
Algorithm that encrypts and decrypts direct messages
Link to this section Summary
Link to this section Functions
@spec decrypt(String.t(), <<_::256>>, <<_::256>>) :: {:ok, String.t()} | {:error, atom() | String.t()}
Decrypts a direct message
examples
Examples
iex> remote_public_key = <<0xEFC83F01C8FB309DF2C8866B8C7924CC8B6F0580AFDDE1D6E16E2B6107C2862C::256>>
...> local_private_key = <<0x4E22DA43418DD934373CBB38A5AB13059191A2B3A51C5E0B67EB1334656943B8::256>>
...> "sWLtVbabr8fzIugnOXo4og==?iv=nxF/xVqbC4JdMRUEC0Jfyg=="
...> |> NostrBasics.Crypto.AES256CBC.decrypt(local_private_key, remote_public_key)
{:ok, "test"}
Encrypts a direct message
The example below can't test for the result, as it changes on every execution...
examples
Examples
iex> remote_public_key = <<0xEFC83F01C8FB309DF2C8866B8C7924CC8B6F0580AFDDE1D6E16E2B6107C2862C::256>>
...> local_private_key = <<0x4E22DA43418DD934373CBB38A5AB13059191A2B3A51C5E0B67EB1334656943B8::256>>
...> "this message will end up being encrypted"
...> |> NostrBasics.Crypto.AES256CBC.encrypt(local_private_key, remote_public_key)