obfuscate 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 77a0600dfa12c2c40e4d07288f340ae357b3e1468b8631e50317b4ad19890afd
4
+ data.tar.gz: 7527e96f6844dc73a34812125f4f2d458e4300b07af84139cd0d9ca6f3ba2049
5
+ SHA512:
6
+ metadata.gz: 69f7bd7e8f56082ab1d47f199c5232beba2bedfe5b85bfbe5d9180b825400c32c1a4159572b3ada8644563e3b67950f58756b71d6e01df74104fc24137edebb7
7
+ data.tar.gz: f96da0558513e01cc0e051da58f394324eb89cd207dd8c41d1b830d3b443a780b37a1d43a96c750a01ee0b67548eb79a4c426ee47a213e7d4a2125c953cc63b0
data/CHANGELOG.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  ### 0.0.7 (May 16, 2013)
4
4
 
5
- * Add :append_salt option to obfuscateable
5
+ * Add :append_salt option to obfuscatable
6
6
 
7
7
  ### 0.0.6 (May 11, 2013)
8
8
 
data/Gemfile.lock CHANGED
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- obfuscate (0.0.6)
4
+ obfuscate (0.1.0)
5
5
  otherinbox-crypt19 (~> 1.2.1)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
- activemodel (3.2.11)
11
- activesupport (= 3.2.11)
12
- builder (~> 3.0.0)
13
- activerecord (3.2.11)
14
- activemodel (= 3.2.11)
15
- activesupport (= 3.2.11)
16
- arel (~> 3.0.2)
17
- tzinfo (~> 0.3.29)
18
- activesupport (3.2.11)
19
- i18n (~> 0.6)
20
- multi_json (~> 1.0)
21
- arel (3.0.2)
22
- builder (3.0.4)
10
+ activemodel (5.2.2)
11
+ activesupport (= 5.2.2)
12
+ activerecord (5.2.2)
13
+ activemodel (= 5.2.2)
14
+ activesupport (= 5.2.2)
15
+ arel (>= 9.0)
16
+ activesupport (5.2.2)
17
+ concurrent-ruby (~> 1.0, >= 1.0.2)
18
+ i18n (>= 0.7, < 2)
19
+ minitest (~> 5.1)
20
+ tzinfo (~> 1.1)
21
+ arel (9.0.0)
23
22
  coderay (1.0.8)
23
+ concurrent-ruby (1.1.3)
24
24
  diff-lcs (1.1.3)
25
25
  ffi (1.3.1)
26
26
  guard (1.6.2)
@@ -32,11 +32,12 @@ GEM
32
32
  guard-rspec (2.4.0)
33
33
  guard (>= 1.1)
34
34
  rspec (~> 2.11)
35
- i18n (0.6.1)
35
+ i18n (1.2.0)
36
+ concurrent-ruby (~> 1.0)
36
37
  listen (0.7.2)
37
38
  lumberjack (1.0.2)
38
39
  method_source (0.8.1)
39
- multi_json (1.5.0)
40
+ minitest (5.11.3)
40
41
  otherinbox-crypt19 (1.2.1)
41
42
  pry (0.9.11.4)
42
43
  coderay (~> 1.0.5)
@@ -53,20 +54,25 @@ GEM
53
54
  diff-lcs (~> 1.1.3)
54
55
  rspec-mocks (2.12.2)
55
56
  slop (3.4.3)
56
- sqlite3 (1.3.7)
57
+ sqlite3 (1.3.13)
57
58
  terminal-table (1.4.5)
58
59
  thor (0.17.0)
59
- tzinfo (0.3.35)
60
- yard (0.8.3)
60
+ thread_safe (0.3.6)
61
+ tzinfo (1.2.5)
62
+ thread_safe (~> 0.1)
63
+ yard (0.9.16)
61
64
 
62
65
  PLATFORMS
63
66
  ruby
64
67
 
65
68
  DEPENDENCIES
66
- activerecord (> 3.0.0)
69
+ activerecord (>= 3.2.22.1)
67
70
  guard-rspec (~> 2.4.0)
68
71
  obfuscate!
69
72
  rb-inotify (~> 0.8.8)
70
73
  rspec (~> 2.12.0)
71
- sqlite3 (~> 1.3.0)
72
- yard (~> 0.8.0)
74
+ sqlite3 (~> 1.3.13)
75
+ yard (>= 0.9.11)
76
+
77
+ BUNDLED WITH
78
+ 1.16.3
data/README.md CHANGED
@@ -44,7 +44,7 @@ Create an initializer in `config/initializers` with:
44
44
  Now add to models that you want to be `Obfuscatable`, with <a href="http://rubydoc.info/gems/obfuscate/Obfuscate/Obfuscatable/ClassMethods">possible config options</a>:
45
45
 
46
46
  class Message < ActiveRecord::Base
47
- obfuscatable # a hash of config overrides can be passed.
47
+ obfuscatable # a hash of config options can be passed.
48
48
  end
49
49
 
50
50
  To get the 11 character `obfuscated_id`, which uses `mode :block` for the Blowfish single block encryption:
@@ -27,7 +27,7 @@ class Obfuscate::Config
27
27
  def mode=(mode)
28
28
  @mode = mode.to_sym
29
29
  end
30
-
30
+
31
31
  def salt=(salt)
32
32
  if salt.length == 0 || salt.length > 56
33
33
  raise "Obfuscate salt length must be between 1-56"
@@ -55,14 +55,12 @@ class Obfuscate::Config
55
55
  def apply(options = {}, &blk)
56
56
  config = self.class.new
57
57
 
58
- changes = self.to_hash.merge( options )
59
-
58
+ changes = self.to_hash.merge(options)
60
59
  config.salt = changes[:salt] unless changes[:salt].nil?
61
60
  config.mode = changes[:mode] unless changes[:mode].nil?
62
61
  config.encode = changes[:encode] unless changes[:encode].nil?
63
62
  config.remove_trailing_equal = changes[:remove_trailing_equal] unless changes[:remove_trailing_equal].nil?
64
63
 
65
-
66
64
  yield(config) if blk
67
65
 
68
66
  config
@@ -18,14 +18,13 @@ require 'crypt/blowfish'
18
18
  require 'base64'
19
19
 
20
20
  class Obfuscate::Crypt
21
-
22
21
  attr_reader :config
23
- attr_reader :exec_config
22
+ attr_reader :exec_config
24
23
 
25
24
  # New instance of Obfuscate::Crypt
26
25
  #
27
26
  # @param [Obfuscate::Config]
28
- def initialize( config )
27
+ def initialize(config)
29
28
  @crypt = Crypt::Blowfish.new( config.salt )
30
29
  @config = config
31
30
  end
@@ -34,9 +33,9 @@ class Obfuscate::Crypt
34
33
  #
35
34
  # @param [Symbol] override_mode to explicit set obfuscate mode to :string or :block
36
35
  # @return [String]
37
- def obfuscate( text, override_mode = nil )
36
+ def obfuscate(text, override_mode = nil)
38
37
 
39
- @exec_config = @config.apply( :mode => (override_mode || @config.mode) )
38
+ @exec_config = @config.apply(:mode => (override_mode || @config.mode) )
40
39
 
41
40
  obfuscated = nil
42
41
  if @exec_config.mode == :string
@@ -14,5 +14,5 @@
14
14
  # the License.
15
15
 
16
16
  module Obfuscate
17
- VERSION = "0.0.7"
17
+ VERSION = "0.1.0"
18
18
  end
data/obfuscate.gemspec CHANGED
@@ -22,7 +22,7 @@ Gem::Specification.new do |s|
22
22
  s.add_development_dependency(%q<rspec>, ["~> 2.12.0"])
23
23
  s.add_development_dependency(%q<guard-rspec>, ["~> 2.4.0"])
24
24
  s.add_development_dependency(%q<rb-inotify>, ["~> 0.8.8"])
25
- s.add_development_dependency(%q<activerecord>, ["> 3.0.0"])
26
- s.add_development_dependency(%q<sqlite3>, ["~> 1.3.0"])
27
- s.add_development_dependency(%q<yard>, ["~> 0.8.0"])
25
+ s.add_development_dependency(%q<activerecord>, [">= 3.2.22.1"])
26
+ s.add_development_dependency(%q<sqlite3>, ["~> 1.3.13"])
27
+ s.add_development_dependency(%q<yard>, [">= 0.9.11"])
28
28
  end
@@ -21,52 +21,50 @@ require 'base64'
21
21
  describe Obfuscate::Crypt do
22
22
 
23
23
  describe "obfuscate block mode" do
24
- before(:each) do
25
- @config = Obfuscate::Config.new.tap do |config|
24
+ let(:config) do
25
+ Obfuscate::Config.new.tap do |config|
26
26
  config.salt = "salt-salt-salt"
27
27
  config.mode = :block
28
28
  end
29
29
  end
30
30
 
31
31
  it "should obfuscate" do
32
- crypt = Obfuscate::Crypt.new( @config )
32
+ crypt = Obfuscate::Crypt.new(config)
33
33
  crypt.obfuscate("test123").should eql "R35tG3YxSQk"
34
34
  end
35
35
 
36
36
  it "should obfuscate including the equality" do
37
- crypt = Obfuscate::Crypt.new( @config.apply(:remove_trailing_equal => false) )
37
+ crypt = Obfuscate::Crypt.new(config.apply(:remove_trailing_equal => false))
38
38
  crypt.obfuscate("test123").should eql "R35tG3YxSQk="
39
39
  end
40
40
 
41
41
  it "should obfuscate without encoding" do
42
- @config.encode.should be_true
43
- crypt = Obfuscate::Crypt.new( @config.apply(:encode => false ) )
44
- @config.encode.should be_true
45
- crypt.obfuscate("without encoding").should eql "\x8F\xC7\xE4\n,2\xA2\xA7"
42
+ crypt = Obfuscate::Crypt.new(config.apply(encode: false))
43
+ crypt.obfuscate("without encoding").unpack('H*').first.should eql "8fc7e40a2c32a2a7"
46
44
  end
47
45
 
48
46
  it "should be able to override mode" do
49
- crypt = Obfuscate::Crypt.new( @config.apply( :mode => :string ) )
47
+ crypt = Obfuscate::Crypt.new(config.apply( :mode => :string ))
50
48
  crypt.obfuscate("test123", :block).should eql "R35tG3YxSQk"
51
49
  end
52
50
  end
53
51
 
54
52
  describe "obfuscate string mode" do
55
- before(:each) do
56
- @config = Obfuscate::Config.new.tap do |config|
53
+ let(:config) do
54
+ Obfuscate::Config.new.tap do |config|
57
55
  config.salt = "salt-salt-salt"
58
56
  config.mode = :string
59
57
  end
60
58
  end
61
59
 
62
60
  it "should obfuscate" do
63
- crypt = Obfuscate::Crypt.new( @config )
61
+ crypt = Obfuscate::Crypt.new(config)
64
62
  #crypt.obfuscate("test12345678").should eql ""
65
63
  crypt.clarify( crypt.obfuscate("test12345678") ).should eql "test12345678"
66
64
  end
67
65
 
68
66
  it "should clarify previously obfuscated text" do
69
- crypt = Obfuscate::Crypt.new( @config )
67
+ crypt = Obfuscate::Crypt.new(config)
70
68
  crypt.clarify( "j65H1jCTYh2uw/lsHweLXMw50aaENXYI" ).should eql "test12345678"
71
69
  crypt.clarify( "4bxm/ijHwq1ekPBYEGFsr+LuJ8EZVa57" ).should eql "test12345678"
72
70
  crypt.clarify( "y2D0gT8x3llEToou6PPbKRagVYX1NeVc" ).should eql "test12345678"
@@ -75,35 +73,35 @@ describe Obfuscate::Crypt do
75
73
 
76
74
 
77
75
  it "should be able to override mode" do
78
- crypt = Obfuscate::Crypt.new( @config.apply( :mode => :block ) )
76
+ crypt = Obfuscate::Crypt.new(config.apply( :mode => :block ))
79
77
 
80
78
  # such a weak spec, but the encrypted string will not be the same every time
81
79
  crypt.obfuscate("test123", :string).should_not eql "3NINgAbOhPc"
82
80
  end
83
81
  end
84
82
 
85
- describe "clarify" do
86
- before(:each) do
87
- @config = Obfuscate.setup do |config|
83
+ describe "#clarify" do
84
+ let(:config) do
85
+ Obfuscate.setup do |config|
88
86
  config.salt = "salt-salt-salt"
89
87
  config.mode = :string
90
88
  end
91
89
  end
92
90
 
93
91
  it "should clarify" do
94
- crypt = Obfuscate::Crypt.new( @config )
92
+ crypt = Obfuscate::Crypt.new(config)
95
93
  enc = crypt.obfuscate("test123456test123456test123456test123456")
96
94
  crypt.clarify(enc).should eql "test123456test123456test123456test123456"
97
95
  end
98
96
 
99
97
  it "should be able to override mode" do
100
- crypt = Obfuscate::Crypt.new( @config )
98
+ crypt = Obfuscate::Crypt.new(config)
101
99
  crypt.clarify( crypt.obfuscate("test123", :block), :block ).should eql "test123"
102
100
  end
103
101
 
104
102
  describe "block mode" do
105
103
  it "will trim text larger than 8 characters" do
106
- crypt = Obfuscate::Crypt.new( @config.apply( :mode => :block ) )
104
+ crypt = Obfuscate::Crypt.new(config.apply(mode: :block))
107
105
  enc = crypt.obfuscate("1234567890")
108
106
  crypt.exec_config.mode.should eql :block
109
107
 
data/spec/spec_helper.rb CHANGED
@@ -15,6 +15,7 @@
15
15
 
16
16
  require 'rubygems'
17
17
  require 'active_record'
18
+ require 'pry'
18
19
 
19
20
  RSpec.configure do |config|
20
21
  config.treat_symbols_as_metadata_keys_with_true_values = true
metadata CHANGED
@@ -1,128 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obfuscate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Michael Guymon
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-17 00:00:00.000000000 Z
11
+ date: 2018-12-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: otherinbox-crypt19
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: 1.2.1
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: 1.2.1
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.12.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ~>
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.12.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: guard-rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 2.4.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 2.4.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rb-inotify
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ~>
59
+ - - "~>"
68
60
  - !ruby/object:Gem::Version
69
61
  version: 0.8.8
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ~>
66
+ - - "~>"
76
67
  - !ruby/object:Gem::Version
77
68
  version: 0.8.8
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: activerecord
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>'
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
- version: 3.0.0
75
+ version: 3.2.22.1
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>'
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
- version: 3.0.0
82
+ version: 3.2.22.1
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: sqlite3
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ~>
87
+ - - "~>"
100
88
  - !ruby/object:Gem::Version
101
- version: 1.3.0
89
+ version: 1.3.13
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ~>
94
+ - - "~>"
108
95
  - !ruby/object:Gem::Version
109
- version: 1.3.0
96
+ version: 1.3.13
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: yard
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ~>
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
- version: 0.8.0
103
+ version: 0.9.11
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ~>
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
- version: 0.8.0
110
+ version: 0.9.11
126
111
  description: Obfuscate
127
112
  email:
128
113
  - mguymon@tobedevoured.com
@@ -130,8 +115,8 @@ executables: []
130
115
  extensions: []
131
116
  extra_rdoc_files: []
132
117
  files:
133
- - .gitignore
134
- - .rspec
118
+ - ".gitignore"
119
+ - ".rspec"
135
120
  - CHANGELOG.md
136
121
  - Gemfile
137
122
  - Gemfile.lock
@@ -154,27 +139,25 @@ files:
154
139
  homepage: https://github.com/mguymon/obfuscate
155
140
  licenses:
156
141
  - MIT
142
+ metadata: {}
157
143
  post_install_message:
158
144
  rdoc_options: []
159
145
  require_paths:
160
146
  - lib
161
147
  required_ruby_version: !ruby/object:Gem::Requirement
162
- none: false
163
148
  requirements:
164
- - - ! '>='
149
+ - - ">="
165
150
  - !ruby/object:Gem::Version
166
151
  version: '0'
167
152
  required_rubygems_version: !ruby/object:Gem::Requirement
168
- none: false
169
153
  requirements:
170
- - - ! '>='
154
+ - - ">="
171
155
  - !ruby/object:Gem::Version
172
156
  version: '0'
173
157
  requirements: []
174
158
  rubyforge_project:
175
- rubygems_version: 1.8.23
159
+ rubygems_version: 2.7.6
176
160
  signing_key:
177
- specification_version: 3
161
+ specification_version: 4
178
162
  summary: Obfuscate
179
163
  test_files: []
180
- has_rdoc: