README.md in lockbox-0.4.8 vs README.md in lockbox-0.4.9
- old
+ new
@@ -771,12 +771,14 @@
2. Per field/uploader
3. Per record
### Master Key
-By default, the master key is used to generate unique keys for each field/uploader. This technique comes from [CipherSweet](https://ciphersweet.paragonie.com/internals/key-hierarchy). The table name and column/uploader name are both used in this process. You can get an individual key with:
+By default, the master key is used to generate unique keys for each field/uploader. This technique comes from [CipherSweet](https://ciphersweet.paragonie.com/internals/key-hierarchy). The table name and column/uploader name are both used in this process.
+You can get an individual key with:
+
```ruby
Lockbox.attribute_key(table: "users", attribute: "email_ciphertext")
```
To rename a table with encrypted columns/uploaders, use:
@@ -818,14 +820,18 @@
To use a different key for each record, use a symbol:
```ruby
class User < ApplicationRecord
encrypts :email, key: :some_method
+end
+```
- def some_method
- # code to get key
- end
+Or a proc:
+
+```ruby
+class User < ApplicationRecord
+ encrypts :email, key: -> { some_method }
end
```
## Key Management
@@ -934,15 +940,9 @@
```ruby
class User < ApplicationRecord
encrypts :email, encode: false
end
-```
-
-or set it globally:
-
-```ruby
-Lockbox.default_options = {encode: false}
```
## Compatibility
It’s easy to read encrypted data in another language if needed.