go_secure 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/go_secure.rb +16 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40e61a38f73a0bcdf75bc9d0bac1036611b6bf0b
|
4
|
+
data.tar.gz: b13d4a1232f3e963018fdd222b29a7f8a2e75a5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8afc1a1bd1a847e613b1e58d5c826af725affaa058ce7fb6df0a6cb65e1bca813bd3911ea6be73f996b9a273663b555e48f3157f9fd45c419290ac0dcc6e2ccc
|
7
|
+
data.tar.gz: 839fb1ba8729e5f83cdaa47c3e7063adba8cabf0ae3b548ea80cf032006578b06c8a8c2d6fc37a4ec8e6ee59ad30e2677f21ee55455ae12464545e73ccda9822
|
data/lib/go_secure.rb
CHANGED
@@ -115,10 +115,18 @@ module GoSecure
|
|
115
115
|
end
|
116
116
|
|
117
117
|
module SecureJson
|
118
|
+
def self.db_encryption(bool)
|
119
|
+
@db_encryption = !!bool
|
120
|
+
end
|
121
|
+
|
118
122
|
def self.load(str)
|
119
123
|
return nil unless str
|
120
|
-
|
121
|
-
|
124
|
+
if str.match(/^\*\*/)
|
125
|
+
JSON.load(str[2..-1])
|
126
|
+
else
|
127
|
+
salt, secret = str.split(/--/, 2)
|
128
|
+
JSON.load(GoSecure.decrypt(secret, salt, "secure_json"))
|
129
|
+
end
|
122
130
|
end
|
123
131
|
|
124
132
|
def self.dump(obj)
|
@@ -128,8 +136,12 @@ module GoSecure
|
|
128
136
|
end
|
129
137
|
|
130
138
|
def self.encrypted_dump(json)
|
131
|
-
|
132
|
-
|
139
|
+
if @db_encryption == false
|
140
|
+
"**" + json
|
141
|
+
else
|
142
|
+
secret, salt = GoSecure.encrypt(json, "secure_json")
|
143
|
+
salt + "--" + secret
|
144
|
+
end
|
133
145
|
end
|
134
146
|
end
|
135
147
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: go_secure
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Whitmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|