serket 0.0.2 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +6 -12
- data/lib/serket/version.rb +1 -1
- data/lib/serket.rb +11 -2
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2f8bf96a313faec1a9264d3584c856f3409102ca
|
4
|
+
data.tar.gz: a743e66518dc65832c9fb905bc530a49d80fe74d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d4dc192b1e5461d33d60636dc4876ce7cb4dadf78be9f434eb0b830e46e4996428ef0d27a8911a29a270a04f3778e362d141e277842b54d8c26fe28ef64daaf
|
7
|
+
data.tar.gz: a10af831390151ec3e85c29e718167af4a645aceddd6e030061d45f710c06c433d8ff57b568d560bd0cf664662633a286e61448013ec08d36fb25f05ee37813c
|
data/README.md
CHANGED
@@ -32,7 +32,7 @@ Serket.configure do |config|
|
|
32
32
|
end
|
33
33
|
```
|
34
34
|
|
35
|
-
You can then
|
35
|
+
You can then encrypt some text:
|
36
36
|
``
|
37
37
|
Serket.encrypt("Hello out there!")
|
38
38
|
``
|
@@ -116,19 +116,13 @@ end
|
|
116
116
|
|
117
117
|
This will automatically decrypt any values before saving assuming it matches your configurations.
|
118
118
|
|
119
|
-
I recommend putting an initializer at config/initializers/serket.rb and putting your serket config block there.
|
119
|
+
I recommend putting an initializer at config/initializers/serket.rb and putting your serket config block there.
|
120
|
+
|
120
121
|
For example:
|
121
122
|
```
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
config.private_key_path = "config/keys/private_key.pem"
|
126
|
-
end
|
127
|
-
else
|
128
|
-
Serket.configure do |config|
|
129
|
-
config.public_key_path = "config/keys/test_public_key.pem"
|
130
|
-
config.private_key_path = "config/keys/test_private_key.pem"
|
131
|
-
end
|
123
|
+
Serket.configure do |config|
|
124
|
+
config.public_key_path = ENV["SERKET_PUBLIC_KEY"]
|
125
|
+
config.private_key_path = ENV["SERKET_PRIVATE_KEY"]
|
132
126
|
end
|
133
127
|
```
|
134
128
|
|
data/lib/serket/version.rb
CHANGED
data/lib/serket.rb
CHANGED
@@ -19,10 +19,19 @@ module Serket
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.encrypt(text)
|
22
|
-
|
22
|
+
field_encrypter.encrypt(text)
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.decrypt(cipher)
|
26
|
-
|
26
|
+
field_decrypter.decrypt(cipher)
|
27
27
|
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def self.field_encrypter
|
31
|
+
@field_encrypter ||= FieldEncrypter.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.field_decrypter
|
35
|
+
@field_decrypter ||= FieldDecrypter.new
|
36
|
+
end
|
28
37
|
end
|