attribute_queryable_encrypted 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/attribute_queryable_encrypted.rb +1 -0
- data/lib/attribute_queryable_encrypted/adapters/active_record.rb +1 -1
- data/lib/attribute_queryable_encrypted/prefix_attributes.rb +2 -1
- data/lib/attribute_queryable_encrypted/version.rb +1 -1
- data/spec/active_record_adapter_spec.rb +1 -1
- metadata +2 -2
@@ -2,6 +2,7 @@ require 'active_support/concern'
|
|
2
2
|
require 'active_support/core_ext/array/extract_options'
|
3
3
|
require 'active_support/core_ext/class/attribute'
|
4
4
|
require 'digest'
|
5
|
+
require 'base64'
|
5
6
|
require 'attribute_queryable_encrypted/core_ext/lower_higher'
|
6
7
|
require 'attribute_queryable_encrypted/core_ext/prefix'
|
7
8
|
require 'attribute_queryable_encrypted/core_ext/stretch_digest'
|
@@ -23,7 +23,7 @@ module AttributeQueryableEncrypted
|
|
23
23
|
|
24
24
|
find_by_method = proc do |original_value|
|
25
25
|
send("find_all_by_#{[options[:prefix], attribute].join('_')}", original_value.prefix(options[:length])).detect do |result|
|
26
|
-
result
|
26
|
+
result.send(attribute).match original_value
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
@@ -67,7 +67,8 @@ module AttributeQueryableEncrypted
|
|
67
67
|
|
68
68
|
def prefix_encrypt(value, options)
|
69
69
|
prefix_encrypted_value = value.prefix(options[:length]).stretch_digest(options)
|
70
|
-
prefix_encrypted_value = [prefix_encrypted_value].pack("m*") if options[:encode]
|
70
|
+
# prefix_encrypted_value = [prefix_encrypted_value].pack("m*") if options[:encode]
|
71
|
+
prefix_encrypted_value = Base64.strict_encode64(prefix_encrypted_value) if options[:encode]
|
71
72
|
prefix_encrypted_value
|
72
73
|
end
|
73
74
|
end
|
@@ -6,7 +6,7 @@ ActiveRecord::Base.establish_connection(:adapter => "sqlite3",
|
|
6
6
|
:database => File.dirname(__FILE__) + "/db/attribute_queryable_encrypted.sqlite3")
|
7
7
|
|
8
8
|
ActiveRecord::Base.logger = Logger.new(STDOUT)
|
9
|
-
ActiveRecord::Base.logger.level =
|
9
|
+
ActiveRecord::Base.logger.level = 1
|
10
10
|
|
11
11
|
load File.dirname(__FILE__) + '/db/schema.rb'
|
12
12
|
|