{"id":16732358,"url":"https://github.com/danielberkompas/cloak_ecto","last_synced_at":"2025-05-14T23:07:10.279Z","repository":{"id":33931614,"uuid":"161959679","full_name":"danielberkompas/cloak_ecto","owner":"danielberkompas","description":"Encrypted fields for Ecto","archived":false,"fork":false,"pushed_at":"2025-03-24T14:39:03.000Z","size":173,"stargazers_count":207,"open_issues_count":11,"forks_count":34,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T20:39:14.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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","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,"zenodo":null}},"created_at":"2018-12-16T02:03:32.000Z","updated_at":"2025-04-04T14:19:47.000Z","dependencies_parsed_at":"2024-06-18T15:36:21.057Z","dependency_job_id":"bc4005b8-27da-4472-8c70-cdb40af75772","html_url":"https://github.com/danielberkompas/cloak_ecto","commit_stats":{"total_commits":71,"total_committers":8,"mean_commits":8.875,"dds":0.09859154929577463,"last_synced_commit":"9989e732c8211c6d867fcd2f2c4843912b24fc8d"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak_ecto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak_ecto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak_ecto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielberkompas%2Fcloak_ecto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielberkompas","download_url":"https://codeload.github.com/danielberkompas/cloak_ecto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254243362,"owners_count":22038046,"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":[],"created_at":"2024-10-12T23:44:03.095Z","updated_at":"2025-05-14T23:07:05.270Z","avatar_url":"https://github.com/danielberkompas.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Cloak.Ecto\n[![Hex Version](http://img.shields.io/hexpm/v/cloak_ecto.svg)](https://hex.pm/packages/cloak_ecto)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/cloak_ecto/)\n[![Total Download](https://img.shields.io/hexpm/dt/cloak_ecto.svg)](https://hex.pm/packages/cloak_ecto)\n[![Last Updated](https://img.shields.io/github/last-commit/danielberkompas/cloak_ecto.svg)](https://github.com/danielberkompas/cloak_ecto/commits/master)\n[![Build Status](https://danielberkompas.semaphoreci.com/badges/cloak_ecto/branches/master.svg?style=shields)](https://danielberkompas.semaphoreci.com/projects/cloak_ecto)\n[![Coverage Status](https://coveralls.io/repos/github/danielberkompas/cloak_ecto/badge.svg)](https://coveralls.io/github/danielberkompas/cloak_ecto)\n\nEasily encrypt fields in your [Ecto](https://github.com/elixir-ecto/ecto)\nschemas. Relies on [Cloak](https://github.com/danielberkompas/cloak) for\nencryption.\n\n- [Hex Documentation](https://hexdocs.pm/cloak_ecto)\n\n## Usage\n\n`Cloak.Ecto` helps you create `Ecto.Type` modules which automatically encrypt\nand decrypt your data. You simply define a type and set the type of your fields, and\n`Cloak.Ecto` handles the rest.\n\n```elixir\ndefmodule MyApp.Encrypted.Binary do\n  use Cloak.Ecto.Binary, vault: MyApp.Vault\nend\n```\n\n```elixir\ndefmodule MyApp.EctoSchema do\n  use Ecto.Schema\n\n  schema \"table_name\" do\n    field :encrypted_field, MyApp.Encrypted.Binary\n\n    # ...\n  end\nend\n```\n\nWhen Ecto writes the fields to the database, Cloak encrypts the values into a\nbinary blob, using a configured encryption algorithm chosen by you.\n\n```elixir\niex\u003e Repo.insert!(%MyApp.EctoSchema{encrypted_field: \"plaintext\"})\n08:46:08.862 [debug] QUERY OK db=3.4ms\nINSERT INTO \"table_name\" (\"encrypted_field\") \nVALUES ($1) RETURNING \"id\", \"encrypted_field\" [\n  \u003c\u003c1,10, 65, 69, 83, 46, 67, 84, 82, 46, 86, 49, \n    69, 92, 173, 219, 203, 238, 26, 58, 236, 5, \n    104, 23, 12, 10, 182, 31, 221, 89, 22, 58, \n    34, 79, 109, 30, 70, 254, 56, 93, 102, 84\u003e\u003e\n]\n```\n\nLikewise, when Ecto reads the encrypted blob out of the database, Cloak will\nautomatically decrypt the value into the intended data type at runtime.\n\n```elixir\niex\u003e Repo.get(MyApp.EctoSchema, 1)\n%MyApp.EctoSchema{encrypted_field: \"plaintext\"}\n```\n\nFor complete usage instructions, see the [Hex documentation](https://hexdocs.pm/cloak_ecto).\n\n## Troubleshooting\n\nSee our [troubleshooting guide](/guides/how_to/troubleshooting.md) for solutions to common issues.\n\n## Notable Features\n\n- Transparent, easy to use encryption for database fields\n- Fully compatible with umbrella projects\n- Bring your own encryption algorithm, if you want\n- Mix task for key rotation: `mix cloak.migrate`\n\n## Security Notes\n\n-  **Supported Algorithms**: Cloak's built-in encryption modules rely on Erlang's \n   `:crypto` module. Cloak supports the following algorithms out of the box:\n   \n    - AES.GCM\n    - AES.CTR\n\n- **Encrypted Data Not Searchable**: Cloak uses random IVs for each ciphertext. This \n  means that the same value will not encrypt to the same value twice. As a result,\n  encrypted columns are not queryable. However, Cloak does provide easy ways to\n  create hashed, searchable columns.\n\n- **Runtime Data is not Encrypted**: Cloak encrypts data _at rest_ in the database. \n  The data in your Ecto structs at runtime is not encrypted.\n\n- **No Support for User-specific Encryption Keys**: Cloak's `Ecto.Type` modules do not\n  support user-specific encryption keys, due to limitations on the `Ecto.Type` \n  behaviour. However, you can still use Cloak's ciphers to implement these in your \n  application logic.\n\n## Use Without Ecto\n\nIf you want to use `Cloak` without Ecto, see\n[`cloak`](https://hex.pm/packages/cloak) instead.\n\n## Local Development\n\nTo develop this library locally, you will need to install the correct version\nof Elixir and Postgres. The easiest way to set everything up is with Docker\nand [docker-compose](https://docs.docker.com/compose/):\n\n```sh\n$ cd cloak_ecto\n# Runs the bin/test script in the context of Docker\n$ docker-compose run code bin/test\n# To access a terminal with mix, use this command:\n$ docker-compose run code bash\n# Run any command of your choosing:\nroot@234098234oij:/app# mix docs\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fcloak_ecto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielberkompas%2Fcloak_ecto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielberkompas%2Fcloak_ecto/lists"}