{"id":17133552,"url":"https://github.com/nsommer/encryptable_attributes","last_synced_at":"2025-07-31T05:04:25.179Z","repository":{"id":32422614,"uuid":"132333087","full_name":"nsommer/encryptable_attributes","owner":"nsommer","description":"Encrypt and decrypt attributes of ActiveRecord models","archived":false,"fork":false,"pushed_at":"2025-03-13T04:46:05.000Z","size":78,"stargazers_count":1,"open_issues_count":66,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-21T19:18:07.791Z","etag":null,"topics":["activerecord","encryption","gem","rails","ruby"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/encryptable_attributes","language":"Ruby","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/nsommer.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","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":"2018-05-06T11:43:26.000Z","updated_at":"2018-05-21T07:49:54.000Z","dependencies_parsed_at":"2024-10-23T00:29:57.374Z","dependency_job_id":null,"html_url":"https://github.com/nsommer/encryptable_attributes","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":"0.032258064516129004","last_synced_commit":"7c80b150b0b81cb5d936c319b0d3005e04fb3f24"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fencryptable_attributes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fencryptable_attributes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fencryptable_attributes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nsommer%2Fencryptable_attributes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nsommer","download_url":"https://codeload.github.com/nsommer/encryptable_attributes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245791245,"owners_count":20672664,"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":["activerecord","encryption","gem","rails","ruby"],"created_at":"2024-10-14T19:42:27.210Z","updated_at":"2025-03-27T05:30:42.130Z","avatar_url":"https://github.com/nsommer.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# EncryptableAttributes [![Build Status](https://travis-ci.org/nsommer/encryptable_attributes.svg?branch=master)](https://travis-ci.org/nsommer/encryptable_attributes) [![Depfu](https://badges.depfu.com/badges/0aa2b808a183e56fa830b90ba072d137/overview.svg)](https://depfu.com/github/nsommer/encryptable_attributes)\n\nWith the `encryptable_attributes` gem, you transparently encrypt and decrypt attributes of an ActiveRecord model. It uses [`ActiveSupport::MessageEncryptor`](http://api.rubyonrails.org/classes/ActiveSupport/MessageEncryptor.html) to encrypt and decrypt values and provides a simple class-level DSL for configuration.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'encryptable_attributes'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install encryptable_attributes\n\n## Usage\n\nConsider a simple ActiveRecord model `Message` with a `title` and a `body` field. To store those attributes' values encrypted, use the following code snippet.\n\n```ruby\nclass Message \u003c ActiveRecord::Base\n  include EncryptableAttributes::Base\n  \n  secure_key ENV.fetch('SECRET_KEY')\n  secure_attrs :title, :body\nend\n```\n\nActiveRecord models use an `attributes` hash internally to keep attributes. EncryptablesAttributes overrides the accessor methods for the corresponding attributes and encrypts given values before storing them in the `attributes` hash and decrypts them when reading them from the `attributes` hash.\n\nIn addition to setting the encryption key statically as shown in the example above, you can also read the key dynamically per model instance via a method call. It looks like this.\n\n```ruby\nclass Message \u003c ActiveRecord::Base\n  include EncryptableAttributes::Base\n  \n  secure_key :individual_message_key\n  secure_attrs :title, :body\n  \n  private\n\n    # Use this to build a message key from other model attributes\n    # or to set it from content fed from outside.\n    def individual_message_key\n      'secret'\n    end\nend\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/nsommer/encryptable_attributes.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsommer%2Fencryptable_attributes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnsommer%2Fencryptable_attributes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnsommer%2Fencryptable_attributes/lists"}