Skip to content
Code for blog post. Example of AES encryption for Elixir Phoenix
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
lib
priv/gettext
test
.gitignore
LICENSE
README.md
mix.exs
mix.lock

README.md

PhoenixAesApi

This is application made for blog post about Ruby and Elixir AES encryption.

The ex_crypto library is used for encryption.

Notice

The application code is written to show example implementation of encryption, and can be used for skeleton of flow with different algorithm supported by ex_crypto or other library. I would not advise using only AES CBC for securing messages on production system. If you are looking for library which will provide complete encryption solution try using libsodium or joken.

Running server

To start your Phoenix server:

  • Install dependencies with mix deps.get
  • Start Phoenix endpoint with mix phx.server

On default port API takes JSON with encrypted format at route: http://localhost:4000/api/encrypted

Example message

The API takes JSON message encrypted with AES 256 CBC initialization vector 2840234823308290 and key this_key_have_to_equal_32_bytes!.

Example message for issuing to api.

{
  "data":"SXaymLAVSvIsCa+OhVh6E4RsHOKGvw1ts98rBCuUGeoqL0a0/3ebatrp0EU9jLSc"
}

Decrypted and deserialized JSON message structure inside app.

{
  "name":"Arnold",
  "surname":"Schwarzeneger"
}

Tests

  • Run tests with mix test

Learn more about Phoenix

You can’t perform that action at this time.