https://github.com/nashiradeer/simple-rijndael-4elixir
Port of PurePeace's simple-rijndael to Elixir.
https://github.com/nashiradeer/simple-rijndael-4elixir
Last synced: 13 days ago
JSON representation
Port of PurePeace's simple-rijndael to Elixir.
- Host: GitHub
- URL: https://github.com/nashiradeer/simple-rijndael-4elixir
- Owner: nashiradeer
- License: mit
- Created: 2024-07-09T00:11:20.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-07-16T22:18:55.000Z (10 months ago)
- Last Synced: 2025-04-22T13:50:15.937Z (27 days ago)
- Language: Elixir
- Homepage:
- Size: 26.4 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# simple-rijndael for Elixir
A binding to the PurePeace's simple-rijndael Rust crate for Elixir.
[
](https://www.paypal.com/donate/?business=QQGMTC3FQAJF6&no_recurring=0&item_name=Thanks+for+donating+for+me%2C+this+helps+me+a+lot+to+continue+developing+and+maintaining+my+projects.¤cy_code=USD)
[
](https://github.com/sponsors/nashiradeer)
[](https://hex.pm/packages/simple_rijndael)
[
](https://hexdocs.pm/simple_rijndael/)## Motivation
AES has removed the block size of 256 bits from the standard and if a old system is using it AES willn't work (my case) and there's no Rijndael implementations in Erlang or Elixir.
## Installation
**Warning:** You will need the [Rust compiler](https://www.rust-lang.org/tools/install) to compile this package.
This package has been published in [Hex.pm](https://hex.pm/packages/simple_rijndael) and you can use it with:
```elixir
def deps do
[
{:simple_rijndael, "~> 0.1.0"}
]
end
```## Usage
```elixir
key = :crypto.strong_rand_bytes(32)
iv = :crypto.strong_rand_bytes(32)# Padding options:
# :pkcs7
# :zero
{:ok, cipher} = SimpleRijndael.init_cbc_mode(key, 32, :pkcs7)data = "Hello, World!"
{:ok, encrypted} = SimpleRijndael.encrypt(cipher, iv, data)
{:ok, decrypted} = SimpleRijndael.decrypt(cipher, iv, encrypted)
# If an error occour, will be one of the following returns:
# {:error, :invalid_data_size}
# {:error, :invalid_key_size}
# {:error, :invalid_block_size}
#
# Or an exception of ErlangError with reason == nil and original == :nif_panicked
```
## Credits**Simple Rijndael for Elixir** is a project by [Nashira Deer](https://github.com/nashiradeer), licensed under [MIT License](https://github.com/nashiradeer/simple-rijndael-4elixir/blob/main/LICENSE.txt).