{"id":13507677,"url":"https://github.com/danielberkompas/cloak","last_synced_at":"2025-05-15T00:10:42.393Z","repository":{"id":41057371,"uuid":"42597632","full_name":"danielberkompas/cloak","owner":"danielberkompas","description":"Elixir encryption library designed for Ecto","archived":false,"fork":false,"pushed_at":"2024-04-06T17:13:17.000Z","size":422,"stargazers_count":597,"open_issues_count":9,"forks_count":54,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-06T17:07:38.647Z","etag":null,"topics":["ecto","elixir","encryption","hex"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danielberkompas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-09-16T15:58:14.000Z","updated_at":"2025-04-04T14:19:54.000Z","dependencies_parsed_at":"2024-04-06T04:29:02.116Z","dependency_job_id":"5addf34c-a5f2-4665-82e0-28bc8afe80ee","html_url":"https://github.com/danielberkompas/cloak","commit_stats":{"total_commits":241,"total_committers":26,"mean_commits":9.26923076923077,"dds":"0.25311203319502074","last_synced_commit":"404727b1b81b60cbbbb5441e72d45ca391e365a0"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielberkompas","download_url":"https://codeload.github.com/danielberkompas/cloak/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248782241,"owners_count":21160716,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ecto","elixir","encryption","hex"],"created_at":"2024-08-01T02:00:37.685Z","updated_at":"2025-04-13T20:41:33.539Z","avatar_url":"https://github.com/danielberkompas.png","language":"Elixir","funding_links":[],"categories":["Cryptography","Elixir","Frameworks and Libs"],"sub_categories":["Elixir"],"readme":"Cloak\n======\n\n[![Hex Version](http://img.shields.io/hexpm/v/cloak.svg)](https://hex.pm/packages/cloak)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/cloak/)\n[![Total Download](https://img.shields.io/hexpm/dt/cloak.svg)](https://hex.pm/packages/cloak)\n[![License](https://img.shields.io/hexpm/l/cloak.svg)](https://github.com/danielberkompas/cloak/blob/master/LICENSE.md)\n[![Last Updated](https://img.shields.io/github/last-commit/danielberkompas/cloak.svg)](https://github.com/danielberkompas/cloak/commits/master)\n[![Build Status](https://danielberkompas.semaphoreci.com/badges/cloak/branches/master.svg?style=shields)](https://danielberkompas.semaphoreci.com/projects/cloak)\n[![Inline docs](http://inch-ci.org/github/danielberkompas/cloak.svg?branch=master)](http://inch-ci.org/github/danielberkompas/cloak)\n[![Coverage Status](https://coveralls.io/repos/github/danielberkompas/cloak/badge.svg?branch=migrate)](https://coveralls.io/github/danielberkompas/cloak?branch=migrate)\n\n\nCloak is an Elixir encryption library that implements several best practices\nand conveniences for Elixir developers:\n\n- Random IVs\n- Tagged ciphertexts\n- Elixir-native configuration\n\n## Documentation\n\n- [Hex Documentation](https://hexdocs.pm/cloak) (Includes installation guide)\n- [How to upgrade from Cloak 0.9.x to 1.0.x](https://hexdocs.pm/cloak/0-9-x_to_1-0-x.html)\n\n## Examples\n\n### Encrypt / Decrypt\n\n```elixir\n{:ok, ciphertext} = MyApp.Vault.encrypt(\"plaintext\")\n# =\u003e {:ok, \u003c\u003c1, 10, 65, 69, 83, 46, 71, 67, 77, 46, 86, 49, 45, 1, 250, 221,\n# =\u003e  189, 64, 26, 214, 26, 147, 171, 101, 181, 158, 224, 117, 10, 254, 140, 207,\n# =\u003e  215, 98, 208, 208, 174, 162, 33, 197, 179, 56, 236, 71, 81, 67, 85, 229,\n# =\u003e  ...\u003e\u003e}\n\nMyApp.Vault.decrypt(ciphertext)\n# =\u003e {:ok, \"plaintext\"}\n```\n\n### Reencrypt With New Algorithm/Key\n\n```elixir\n\"plaintext\"\n|\u003e MyApp.Vault.encrypt!(:aes_256)\n|\u003e MyApp.Vault.decrypt!()\n|\u003e MyApp.Vault.encrypt!(:aes_256)\n|\u003e MyApp.Vault.decrypt!()\n# =\u003e \"plaintext\"\n```\n\n### Configuration\n\n```elixir\nconfig :my_app, MyApp.Vault,\n  ciphers: [\n    # In AES.GCM, it is important to specify 12-byte IV length for\n    # interoperability with other encryption software. See this GitHub issue\n    # for more details: https://github.com/danielberkompas/cloak/issues/93\n    #\n    # In Cloak 2.0, this will be the default iv length for AES.GCM.\n    aes_gcm: {Cloak.Ciphers.AES.GCM, tag: \"AES.GCM.V1\", key: \u003c\u003c...\u003e\u003e, iv_length: 12},\n    aes_ctr: {Cloak.Ciphers.AES.CTR, tag: \"AES.CTR.V1\", key: \u003c\u003c...\u003e\u003e}\n  ]\n```\n\n## Features\n\n### Random Initialization Vectors (IV)\n\nEvery strong encryption algorithm recommends unique initialization vectors.\nCloak automatically generates unique vectors using\n`:crypto.strong_rand_bytes`, and includes the IV in the ciphertext.\nThis greatly simplifies storage and is not a security risk.\n\n### Tagged Ciphertext\n\nEach ciphertext contains metadata about the algorithm and key which was used\nto encrypt it. This allows Cloak to automatically select the correct key and\nalgorithm to use for decryption for any given ciphertext.\n\nThis makes key rotation much easier, because you can easily tell whether any\ngiven ciphertext is using the old key or the new key.\n\n### Elixir-Native Configuration\n\nCloak works through `Vault` modules which you define in your app, and add\nto your supervision tree.\n\nYou can have as many vaults as you wish running simultaneously in your\nproject. (This works well with umbrella apps, or any runtime environment\nwhere you have multiple OTP apps using Cloak)\n\n### Ecto Support\n\nYou can use Cloak to transparently encrypt Ecto fields, using\n[`cloak_ecto`](https://hex.pm/packages/cloak_ecto).\n\n## Security Notes\n\n- Cloak is built on Erlang's `crypto` library, and therefore inherits its security.\n- You can implement your own cipher modules to use with Cloak, which may use any other encryption algorithms of your choice.\n\n## Copyright and License\n\nCopyright (c) 2015 Daniel Berkompas\n\nThis work is free. You can redistribute it and/or modify it under the\nterms of the MIT License. See the [LICENSE.md](./LICENSE.md) file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fcloak","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielberkompas%2Fcloak","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fcloak/lists"}