{"id":22025178,"url":"https://github.com/drexed/lite-encryption","last_synced_at":"2025-05-07T09:34:03.160Z","repository":{"id":35078790,"uuid":"204202312","full_name":"drexed/lite-encryption","owner":"drexed","description":"ActiveSupport::MessageEncryptor encryption wrapper for PORO objects and ActiveModel attributes","archived":false,"fork":false,"pushed_at":"2023-03-08T20:15:13.000Z","size":60,"stargazers_count":1,"open_issues_count":6,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T17:45:00.286Z","etag":null,"topics":["activemodel","activerecord","decryption","encryption","rails","ruby"],"latest_commit_sha":null,"homepage":"https://drexed.github.io/lite-encryption","language":"Ruby","has_issues":false,"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/drexed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-08-24T19:21:28.000Z","updated_at":"2023-09-04T16:39:10.000Z","dependencies_parsed_at":"2024-11-15T05:28:36.213Z","dependency_job_id":null,"html_url":"https://github.com/drexed/lite-encryption","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.045454545454545414","last_synced_commit":"e45c9572a60508cd4107ad7709f2396b9f1f19c9"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-encryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-encryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-encryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-encryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/lite-encryption/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252851573,"owners_count":21814173,"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":["activemodel","activerecord","decryption","encryption","rails","ruby"],"created_at":"2024-11-30T07:14:50.872Z","updated_at":"2025-05-07T09:34:03.136Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","readme":"# Lite::Encryption\n\n[![Gem Version](https://badge.fury.io/rb/lite-encryption.svg)](http://badge.fury.io/rb/lite-encryption)\n[![Build Status](https://travis-ci.org/drexed/lite-encryption.svg?branch=master)](https://travis-ci.org/drexed/lite-encryption)\n\nLite::Encryption is a ActiveSupport::MessageEncryptor and OpenSSL::Cipher::Cipher wrapper libraries\nfor encrypting and decrypting PORO object values and model attributes.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lite-encryption'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lite-encryption\n\n## Table of Contents\n\n* [Configurations](#configurations)\n* [Key](#key)\n* [Schemes](#schemes)\n* [Message](#message)\n* [Attribute](#attribute)\n\n## Configurations\n\n`rails g lite:encryption:install` will generate the following file:\n`../config/initalizers/lite_encryption.rb`\n\n```ruby\nLite::Encryption.configure do |config|\n  config.encryption_iv = ENV['ENCRYPTION_IV']\n  config.encryption_key = ENV['ENCRYPTION_KEY']\n  config.encryption_salt = ENV['ENCRYPTION_SALT']\nend\n```\n\n## Key\n\nUse the following to generate encryption values that you can then add to your\ncredentials or ENV variables.\n\n```ruby\nLite::Encryption::Key.generate_iv       #=\u003e \"\\x9C\\x9F5\u003c\\xA5\\x9B\\x97\\x97\\xE2\\x1DQ\\x05\"\nLite::Encryption::Key.generate_key      #=\u003e \"y\\x0Eo\\xC1Gll\\x05Qv\\x11[\\xE1vN8\u003c\\xAFxU_\\xCB\\xD7\\x02)0\\xC1#\\x99\\xDD4N\"\nLite::Encryption::Key.generate_password #=\u003e \"289b4997f758b31693d3315679d9fa7c\"\nLite::Encryption::Key.generate_salt     #=\u003e \"\\xD2\\xBA\\x9B\\x81@e\\x99\\x8BN\\a7\\xC2\\x95)f\\x97k\\xC9EM\\xE0x\\xFBO\\x9BERBD\\x85%n\"\n```\n\n## Schemes\n\nThe non-deterministic message class is the wrapper class for `ActiveSupport::MessageEncryptor` so\nyou can pass it accepted options.\n\nThe deterministic message class is the wrapper class for `OpenSSL::Cipher::Cipher` so\nyou can pass it accepted options.\n\n```ruby\nLite::Encryption::Schemes::NonDeterministic.encrypt('decrypted_text', purpose: 'sec-pur')\nLite::Encryption::Schemes::NonDeterministic.decrypt('==encrypted_text')\n\n# - or -\n\nservice = Lite::Encryption::Deterministic.new\n\nservice.encrypt('decrypted_text')\nservice.decrypt('==encrypted_text')\n```\n\n## Message\n\nThe message class is the wrapper class for both schemes so you can pass it accepted options.\n\n```ruby\nLite::Encryption::Message.encrypt('decrypted_text', purpose: 'sec-pur')\nLite::Encryption::Message.decrypt('==encrypted_text')\n\n# - or -\n\nservice = Lite::Encryption::Message.new\n\nservice.encrypt('decrypted_text', expires_in: 2.hours)\nservice.decrypt('==encrypted_text')\n\n# - or -\n\nLite::Encryption::Message.encrypt('decrypted_text', deterministic: true)\nLite::Encryption::Message.decrypt('==encrypted_text', deterministic: true)\n\n# - or -\n\nservice = Lite::Encryption::Message.new\n\nservice.encrypt('decrypted_text', deterministic: true)\nservice.decrypt('==encrypted_text', deterministic: true)\n```\n\n## Attribute\n\nThe attribute module provides a handy method for encrypting and decrypting attributes.\nYou must add an `encrypted_*[column_name]` attribute to your database table like\n`encrypted_number`. You can then add code like the following for it to automatically\nencrypt and decrypt your values.\n\n```ruby\nclass CreditCard \u003c ActiveRecord::Base\n  extend Lite::Encryption::Attribute\n\n  attr_encrypt :name, deterministic: true\n  attr_encrypt :number, :cvv, purpose: 'payment-menthod'\n\nend\n```\n\nYou can then access attributes using the following:\n\n```ruby\ncredit_card = CreditCard.create(number: '1234')\n\ncredit_card.encrypted_number #=\u003e '==encrypted_text'\ncredit_card.decrypted_number #=\u003e '1234'\ncredit_card.number           #=\u003e '1234'\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` 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/[USERNAME]/lite-encryption. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Lite::Encryption project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lite-encryption/blob/master/CODE_OF_CONDUCT.md).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-encryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Flite-encryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-encryption/lists"}