Skip to content

AES cipher in CTR mode implementation using Elixir

License

Notifications You must be signed in to change notification settings

knledg/aes-ctr-ex

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AES CTR

AES cipher in CTR mode.

Installation

If available in Hex, the package can be installed as:

  • Add aes_ctr to your list of dependencies in mix.exs:
def deps do
  [{:aes_ctr, "~> 0.1.0"}]
end
  • Ensure aes_ctr_ex is started before your application:
def application do
  [applications: [:aes_ctr]]
end

Usage

  • Generate AES_128 key:
{:ok, key} = AesCtr.generate_aes_key(:bytes)
{:ok, key_in_base64} = AesCtr.generate_aes_key(:base64)
  • Generate AES_256 key:
{:ok, key} = AesCtr.generate_aes_key(:bytes, 256)
{:ok, key_in_base64} = AesCtr.generate_aes_key(:base64, 256)
  • Encrypt text:
clear_text = "my-clear-text"
{:ok, aes_128_key} = AesCtr.generate_aes_key(:bytes)
{:ok, cipher} = AesCtr.encrypt(aes_128_key, clear_text)
  • Decrypt cipher:
clear_text = "my-clear-text"
{:ok, aes_128_key} = AesCtr.generate_aes_key(:bytes)
{:ok, cipher} = AesCtr.encrypt(clear_text, aes_128_key)
{:ok, val} = AesCtr.decrypt(cipher, aes_128_key)

About

AES cipher in CTR mode implementation using Elixir

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Elixir 100.0%