ProductPromotion
Logo

Elixir

made by https://0x3d.site

GitHub - danielberkompas/cloak: Elixir encryption library designed for Ecto
Elixir encryption library designed for Ecto. Contribute to danielberkompas/cloak development by creating an account on GitHub.
Visit Site

GitHub - danielberkompas/cloak: Elixir encryption library designed for Ecto

GitHub - danielberkompas/cloak: Elixir encryption library designed for Ecto

Cloak

Hex Version Hex Docs Total Download License Last Updated Build Status Inline docs Coverage Status

Cloak is an Elixir encryption library that implements several best practices and conveniences for Elixir developers:

  • Random IVs
  • Tagged ciphertexts
  • Elixir-native configuration

Documentation

Examples

Encrypt / Decrypt

{:ok, ciphertext} = MyApp.Vault.encrypt("plaintext")
# => {:ok, <<1, 10, 65, 69, 83, 46, 71, 67, 77, 46, 86, 49, 45, 1, 250, 221,
# =>  189, 64, 26, 214, 26, 147, 171, 101, 181, 158, 224, 117, 10, 254, 140, 207,
# =>  215, 98, 208, 208, 174, 162, 33, 197, 179, 56, 236, 71, 81, 67, 85, 229,
# =>  ...>>}

MyApp.Vault.decrypt(ciphertext)
# => {:ok, "plaintext"}

Reencrypt With New Algorithm/Key

"plaintext"
|> MyApp.Vault.encrypt!(:aes_256)
|> MyApp.Vault.decrypt!()
|> MyApp.Vault.encrypt!(:aes_256)
|> MyApp.Vault.decrypt!()
# => "plaintext"

Configuration

config :my_app, MyApp.Vault,
  ciphers: [
    # In AES.GCM, it is important to specify 12-byte IV length for
    # interoperability with other encryption software. See this GitHub issue
    # for more details: https://github.com/danielberkompas/cloak/issues/93
    #
    # In Cloak 2.0, this will be the default iv length for AES.GCM.
    aes_gcm: {Cloak.Ciphers.AES.GCM, tag: "AES.GCM.V1", key: <<...>>, iv_length: 12},
    aes_ctr: {Cloak.Ciphers.AES.CTR, tag: "AES.CTR.V1", key: <<...>>}
  ]

Features

Random Initialization Vectors (IV)

Every strong encryption algorithm recommends unique initialization vectors. Cloak automatically generates unique vectors using :crypto.strong_rand_bytes, and includes the IV in the ciphertext. This greatly simplifies storage and is not a security risk.

Tagged Ciphertext

Each ciphertext contains metadata about the algorithm and key which was used to encrypt it. This allows Cloak to automatically select the correct key and algorithm to use for decryption for any given ciphertext.

This makes key rotation much easier, because you can easily tell whether any given ciphertext is using the old key or the new key.

Elixir-Native Configuration

Cloak works through Vault modules which you define in your app, and add to your supervision tree.

You can have as many vaults as you wish running simultaneously in your project. (This works well with umbrella apps, or any runtime environment where you have multiple OTP apps using Cloak)

Ecto Support

You can use Cloak to transparently encrypt Ecto fields, using cloak_ecto.

Security Notes

  • Cloak is built on Erlang's crypto library, and therefore inherits its security.
  • You can implement your own cipher modules to use with Cloak, which may use any other encryption algorithms of your choice.

Copyright and License

Copyright (c) 2015 Daniel Berkompas

This work is free. You can redistribute it and/or modify it under the terms of the MIT License. See the LICENSE.md file for more details.

Articles
to learn more about the elixir concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here 🔥.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here 🔥.

Queries
or most google FAQ's about Elixir.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory