Skip to content

Commit 11df93a

Browse files
authored
Merge pull request #333 from ankane/unique_iv
Make note about unique key/IV pair more prominent in docs
2 parents cc05f95 + 4259da8 commit 11df93a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ Create or modify the table that your model uses to add a column with the `encryp
8787

8888
You can use a string or binary column type. (See the encode option section below for more info)
8989

90+
If you use the same key for each record, add a unique index on the IV. Repeated IVs with AES-GCM (the default algorithm) allow an attacker to recover the key.
91+
92+
```ruby
93+
add_index :users, :encrypted_ssn_iv, unique: true
94+
```
95+
9096
### Specifying the encrypted attribute name
9197

9298
By default, the encrypted attribute name is `encrypted_#{attribute}` (e.g. `attr_encrypted :email` would create an attribute named `encrypted_email`). So, if you're storing the encrypted attribute in the database, you need to make sure the `encrypted_#{attribute}` field exists in your table. You have a couple of options if you want to name your attribute or db column something else, see below for more details.

0 commit comments

Comments
 (0)