-
Notifications
You must be signed in to change notification settings - Fork 0
/
README
47 lines (33 loc) · 1.34 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Has Encrypted Attributes
=====================================
Allows a model to store attributes encrypted in the database. It seamlessly
encrypts/decrypts the data for use within the application.
Set the key in the definition using :key => <key string> or by providing an
association that contains the key.
Using :except in the definition allows for unencrypted attributes in the mix.
By default the _id of the association is excluded (ie: user_id), if needed
and the usual created_at, updated_at, created_on, updated_on columns.
Requires:
Ruby compiled with OpenSSL turned on (and in turn with Blowfish turned on)
Example
=====================================
Inline key:
class Secrets
has_encrypted_attributes :key => 'THIS IS MY KEY TEXT'
end
Key residing on an association:
class MoreSecrets
has_encrypted_attributes :association => :user
# looks for key in self.user.key
end
Key residing on an association (with a custom name for the key):
class StillMoreSecrets
has_encrypted_attributes :association => :user, :key_method => :salt
# looks for key in self.user.salt
end
You can also encrypt only some of the model attributes:
class MostSecrets
has_encrypted_attributes :except => [:year, :count]
# will not try to encrypt year and count attributes
end
Copyright (c) 2008, 2009 Shawn Veader & Jordi Bunster. Licensed under MIT's.