ssoper-acts_as_encryptable 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Changelog CHANGED
@@ -1,3 +1,8 @@
1
+ == 3-29-2009
2
+
3
+ * Fixed errors that were occurring with encryption/decryption due to chunk size
4
+
5
+
1
6
  == 3-27-2009
2
7
 
3
8
  * Fixed tests so that SQLite files are stored in /tmp
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "acts_as_encryptable"
3
- s.version = "1.0.7"
3
+ s.version = "1.0.8"
4
4
  s.date = "2009-03-28"
5
5
  s.author = "Sean Soper"
6
6
  s.email = "sean.soper@gmail.com"
@@ -1,7 +1,7 @@
1
1
  module ActsAsEncryptable
2
2
  module Base
3
3
  WARNING_MSG = "\n \e[0m\e[1;36m[\e[37mActsAsEncryptable\e[36m] \e[1;31mUsing the provided sample keys in production mode is highly discouraged. Generate your own RSA keys using the provided crypto libraries.\e[0m\n\n"
4
- MAX_CHUNK_SIZE = 118
4
+ MAX_CHUNK_SIZE = 115
5
5
  ENCRYPTED_CHUNK_SIZE = 175
6
6
 
7
7
  def self.included(base)
@@ -11,9 +11,8 @@ module ActsAsEncryptable
11
11
  module ClassMethods
12
12
  def acts_as_encryptable(*args)
13
13
  self.class_eval do
14
- has_many :encrypted_chunks, :as => :encryptable
15
14
  before_save :encrypt!
16
-
15
+
17
16
  sample_key_public = File.join(File.dirname(__FILE__), '/../../sample_keys/rsa_key.pub')
18
17
  sample_key_private = File.join(File.dirname(__FILE__), '/../../sample_keys/rsa_key')
19
18
 
@@ -29,6 +28,8 @@ module ActsAsEncryptable
29
28
  RAILS_DEFAULT_LOGGER.warn WARNING_MSG
30
29
  end
31
30
 
31
+ args = args.first if args.first.is_a? Array
32
+
32
33
  write_inheritable_attribute(:encrypted_fields, args.uniq)
33
34
  class_inheritable_reader :encrypted_fields
34
35
 
@@ -51,13 +52,12 @@ module ActsAsEncryptable
51
52
  def chunkize(str, chunk_size)
52
53
  (0..((str.length/chunk_size.to_f).ceil - 1)).each do |x|
53
54
  start, stop = x * chunk_size, (x + 1) * chunk_size
54
- start += 1 if start > 0
55
- yield str[start..stop]
55
+ yield str[start,stop]
56
56
  end
57
57
  end
58
58
  end
59
59
 
60
- module InstanceMethods
60
+ module InstanceMethods
61
61
  def encrypt!
62
62
  yaml_data = self.class.encrypted_fields.inject({}) do |result, field|
63
63
  result.merge!(field => instance_variable_get("@#{field}".to_sym))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssoper-acts_as_encryptable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.7
4
+ version: 1.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Soper