go_secure 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/go_secure.rb +16 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e03f684aa71c0ea293b16228ef7ddb2a49cec19b
4
- data.tar.gz: efca779a729154a524e2c3b9cb6fa76db0dfba80
3
+ metadata.gz: 40e61a38f73a0bcdf75bc9d0bac1036611b6bf0b
4
+ data.tar.gz: b13d4a1232f3e963018fdd222b29a7f8a2e75a5c
5
5
  SHA512:
6
- metadata.gz: 20d03c5c5e05a8d494c7e267016954b0523ba5ae1fe0135c9428331adcee562681295cc037e4a71d97bd3d39a7f1a90cf8a319894a0b09fd7b73334c0e275bd6
7
- data.tar.gz: 6d702b2fcff177d7ed53fbb9b634ab6fa48debfb19d49da3b567f5ee3ca99ccc7aac12006fb4f11b9335d5553974c46b1dd6662ebb5807e0ada4d440f385d943
6
+ metadata.gz: 8afc1a1bd1a847e613b1e58d5c826af725affaa058ce7fb6df0a6cb65e1bca813bd3911ea6be73f996b9a273663b555e48f3157f9fd45c419290ac0dcc6e2ccc
7
+ data.tar.gz: 839fb1ba8729e5f83cdaa47c3e7063adba8cabf0ae3b548ea80cf032006578b06c8a8c2d6fc37a4ec8e6ee59ad30e2677f21ee55455ae12464545e73ccda9822
@@ -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
- salt, secret = str.split(/--/, 2)
121
- JSON.load(GoSecure.decrypt(secret, salt, "secure_json"))
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
- secret, salt = GoSecure.encrypt(json, "secure_json")
132
- salt + "--" + secret
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.1'
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-07-11 00:00:00.000000000 Z
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec