obfuscated 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/obfuscated.rb +4 -3
  2. metadata +5 -5
data/lib/obfuscated.rb CHANGED
@@ -2,7 +2,8 @@ require 'digest/sha1'
2
2
  require 'active_record'
3
3
 
4
4
  module Obfuscated
5
-
5
+ mattr_accessor :salt
6
+
6
7
  def self.append_features(base)
7
8
  super
8
9
  base.extend(ClassMethods)
@@ -27,7 +28,7 @@ module Obfuscated
27
28
  return find_by_id(hash, options) unless Obfuscated::supported?
28
29
 
29
30
  # Update the conditions to use the hash calculation
30
- options.update(:conditions => ["SUBSTRING(SHA1(CONCAT('---',#{self.table_name}.id,'-WICKED-#{self.table_name}-')),1,12) = ?", hash])
31
+ options.update(:conditions => ["SUBSTRING(SHA1(CONCAT('---',#{self.table_name}.id,'-WICKED-#{self.table_name}-#{Obfuscated::salt}')),1,12) = ?", hash])
31
32
 
32
33
  # Find it!
33
34
  first(options) or raise ActiveRecord::RecordNotFound, "Couldn't find #{self.class.to_s} with Hashed ID=#{hash}"
@@ -48,7 +49,7 @@ module Obfuscated
48
49
 
49
50
  # Use SHA1 to generate a consistent hash based on the id and the table name
50
51
  @hashed_id ||= Digest::SHA1.hexdigest(
51
- "---#{id}-WICKED-#{self.class.table_name}-"
52
+ "---#{id}-WICKED-#{self.class.table_name}-#{Obfuscated::salt}"
52
53
  )[0..11]
53
54
  end
54
55
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obfuscated
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Collier
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-03-20 00:00:00 Z
18
+ date: 2012-05-10 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
72
72
  requirements: []
73
73
 
74
74
  rubyforge_project:
75
- rubygems_version: 1.8.18
75
+ rubygems_version: 1.8.24
76
76
  signing_key:
77
77
  specification_version: 3
78
78
  summary: Primary Key Obfuscation