README.md in blind_index-0.1.0 vs README.md in blind_index-0.1.1

- old
+ new

@@ -1,14 +1,16 @@ # Blind Index -Securely query encrypted database fields +Securely search encrypted database fields Designed for use with [attr_encrypted](https://github.com/attr-encrypted/attr_encrypted) +[![Build Status](https://travis-ci.org/ankane/blind_index.svg?branch=master)](https://travis-ci.org/ankane/blind_index) + ## How It Works -We use [this approach](https://www.sitepoint.com/how-to-search-on-securely-encrypted-database-fields/) described by Scott Arciszewski. To summarize, we compute a keyed hash of the sensitive data and store it in a column. To query, we apply the keyed hash function (PBKDF2-HMAC-SHA256) to the value we’re searching and then perform a database search. This results in performant queries for equality operations, while keeping the data secure from those without the key. +This project uses [this approach](https://www.sitepoint.com/how-to-search-on-securely-encrypted-database-fields/) by Scott Arciszewski. To summarize, we compute a keyed hash of the sensitive data and store it in a column. To query, we apply the keyed hash function (PBKDF2-HMAC-SHA256) to the value we’re searching and then perform a database search. This results in performant queries for equality operations, while keeping the data secure from those without the key. ## Getting Started Add these lines to your application’s Gemfile: @@ -68,11 +70,11 @@ You can apply expressions to attributes before indexing and searching. This gives you the the ability to perform case-insensitive searches and more. ```ruby class User < ApplicationRecord - blind_index :email, expression: -> (v) { v.downcase } ... + blind_index :email, expression: ->(v) { v.downcase } ... end ``` ## Multiple Indexes @@ -86,11 +88,11 @@ And update your model ```ruby class User < ApplicationRecord blind_index :email, ... - blind_index :email_ci, attribute: :email, expression: -> (v) { v.downcase } ... + blind_index :email_ci, attribute: :email, expression: ->(v) { v.downcase } ... end ``` Search with: @@ -107,9 +109,21 @@ blind_index :email, iterations: 1000000, ... end ``` The default is `10000`. Changing this value requires you to recompute the blind index. + +## Index Only + +If you don’t need to store the original value (for instance, when just checking duplicates), use a virtual attribute: + +```ruby +class User < ApplicationRecord + attribute :email + + blind_index :email, ... +end +``` ## History View the [changelog](https://github.com/ankane/blind_index/blob/master/CHANGELOG.md)