encrypted_strings 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,5 +1,9 @@
1
1
  *SVN*
2
2
 
3
+ *0.0.4* (May 5th, 2008)
4
+
5
+ * Updated documentation
6
+
3
7
  *0.0.3* (September 18th, 2007)
4
8
 
5
9
  * Remove gem dependency on activesupport
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2005 Rick Olson, 2006-2007 Aaron Pfeifer & Neil Abraham
1
+ Copyright (c) 2005 Rick Olson, 2006-2008 Aaron Pfeifer
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
17
  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
18
  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
19
  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README CHANGED
@@ -4,25 +4,21 @@
4
4
 
5
5
  == Resources
6
6
 
7
- API
8
-
9
- * http://api.pluginaweek.org/encrypted_strings
10
-
11
7
  Wiki
12
8
 
13
9
  * http://wiki.pluginaweek.org/Encrypted_strings
14
10
 
15
- Announcement
11
+ API
16
12
 
17
- * http://www.pluginaweek.org
13
+ * http://api.pluginaweek.org/encrypted_strings
18
14
 
19
- Source
15
+ Development
20
16
 
21
- * http://svn.pluginaweek.org/trunk/plugins/ruby/string/encrypted_strings
17
+ * http://dev.pluginaweek.org/browse/trunk/encrypted_strings
22
18
 
23
- Development
19
+ Source
24
20
 
25
- * http://dev.pluginaweek.org/browse/trunk/plugins/ruby/string/encrypted_strings
21
+ * http://svn.pluginaweek.org/trunk/encrypted_strings
26
22
 
27
23
  == Description
28
24
 
@@ -85,7 +81,7 @@ the resulting encrypted value is the same.
85
81
 
86
82
  == Dependencies
87
83
 
88
- This plugin does not depend on the presence of any other plugins.
84
+ None.
89
85
 
90
86
  == References
91
87
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake/gempackagetask'
4
4
  require 'rake/contrib/sshpublisher'
5
5
 
6
6
  PKG_NAME = 'encrypted_strings'
7
- PKG_VERSION = '0.0.3'
7
+ PKG_VERSION = '0.0.4'
8
8
  PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
9
9
  RUBY_FORGE_PROJECT = 'pluginaweek'
10
10
 
@@ -39,8 +39,8 @@ spec = Gem::Specification.new do |s|
39
39
  s.has_rdoc = true
40
40
  s.test_files = Dir['test/**/*_test.rb']
41
41
 
42
- s.author = 'Aaron Pfeifer, Neil Abraham'
43
- s.email = 'info@pluginaweek.org'
42
+ s.author = 'Aaron Pfeifer'
43
+ s.email = 'aaron@pluginaweek.org'
44
44
  s.homepage = 'http://www.pluginaweek.org'
45
45
  end
46
46
 
@@ -52,12 +52,12 @@ end
52
52
 
53
53
  desc 'Publish the beta gem'
54
54
  task :pgem => [:package] do
55
- Rake::SshFilePublisher.new('pluginaweek@pluginaweek.org', '/home/pluginaweek/gems.pluginaweek.org/gems', 'pkg', "#{PKG_FILE_NAME}.gem").upload
55
+ Rake::SshFilePublisher.new('aaron@pluginaweek.org', '/home/aaron/gems.pluginaweek.org/public/gems', 'pkg', "#{PKG_FILE_NAME}.gem").upload
56
56
  end
57
57
 
58
58
  desc 'Publish the API documentation'
59
59
  task :pdoc => [:rdoc] do
60
- Rake::SshDirPublisher.new('pluginaweek@pluginaweek.org', "/home/pluginaweek/api.pluginaweek.org/#{PKG_NAME}", 'rdoc').upload
60
+ Rake::SshDirPublisher.new('aaron@pluginaweek.org', "/home/aaron/api.pluginaweek.org/public/#{PKG_NAME}", 'rdoc').upload
61
61
  end
62
62
 
63
63
  desc 'Publish the API docs and gem'
@@ -23,7 +23,7 @@ module PluginAWeek #:nodoc:
23
23
  # default values will be used. You can override the default values like so:
24
24
  #
25
25
  # password = "shhhh"
26
- # password.encrypt(:asymmetic, :public_key_file => "./encrypted_public.key") # => "INy95irZ8AlHmvc6ZAF/ARsTpbqPIB/4bEAKKOebjsayB7NYWtIzpswvzxqf\nNJ5yyuvxfMODrcg7RimEMFkFlg==\n"
26
+ # password.encrypt(:asymmetric, :public_key_file => "./encrypted_public.key") # => "INy95irZ8AlHmvc6ZAF/ARsTpbqPIB/4bEAKKOebjsayB7NYWtIzpswvzxqf\nNJ5yyuvxfMODrcg7RimEMFkFlg==\n"
27
27
  #
28
28
  # An exception will be raised if either the public key file could not be
29
29
  # found or the key could not decrypt the public key file.
@@ -44,7 +44,7 @@ module PluginAWeek #:nodoc:
44
44
  # default values will be used. You can override the default values like so:
45
45
  #
46
46
  # password = "INy95irZ8AlHmvc6ZAF/ARsTpbqPIB/4bEAKKOebjsayB7NYWtIzpswvzxqf\nNJ5yyuvxfMODrcg7RimEMFkFlg==\n"
47
- # password.decrypt(:asymmetic, :public_key_file => "./encrypted_private.key", :key => "secret") # => "shhhh"
47
+ # password.decrypt(:asymmetric, :public_key_file => "./encrypted_private.key", :key => "secret") # => "shhhh"
48
48
  #
49
49
  # An exception will be raised if either the private key file could not be
50
50
  # found or the key could not decrypt the private key file.
@@ -67,10 +67,10 @@ module PluginAWeek #:nodoc:
67
67
  attr_accessor :key
68
68
 
69
69
  # Configuration options:
70
- # * <tt>private_key_file</tt> - Encrypted private key file
71
- # * <tt>public_key_file</tt> - Public key file
72
- # * <tt>key</tt> - The key to use in the symmetric encryptor
73
- # * <tt>algorithm</tt> - Algorithm to use symmetrically encrypted strings
70
+ # * +private_key_file+ - Encrypted private key file
71
+ # * +public_key_file+ - Public key file
72
+ # * +key+ - The key to use in the symmetric encryptor
73
+ # * +algorithm+ - Algorithm to use symmetrically encrypted strings
74
74
  def initialize(options = {})
75
75
  options = options.symbolize_keys
76
76
  options.assert_valid_keys(
@@ -86,8 +86,8 @@ module PluginAWeek #:nodoc:
86
86
  )
87
87
 
88
88
  @public_key = @private_key = nil
89
- @key = options[:key]
90
- @algorithm = options[:algorithm]
89
+ self.key = options[:key]
90
+ self.algorithm = options[:algorithm]
91
91
 
92
92
  self.private_key_file = options[:private_key_file]
93
93
  self.public_key_file = options[:public_key_file]
@@ -97,7 +97,7 @@ module PluginAWeek #:nodoc:
97
97
 
98
98
  # Encrypts the given data
99
99
  def encrypt(data)
100
- raise NoPublicKeyError, "Public key file: #{@public_key_file}" unless public?
100
+ raise NoPublicKeyError, "Public key file: #{public_key_file}" unless public?
101
101
 
102
102
  encrypted_data = public_rsa.public_encrypt(data)
103
103
  Base64.encode64(encrypted_data)
@@ -105,7 +105,7 @@ module PluginAWeek #:nodoc:
105
105
 
106
106
  # Decrypts the given data
107
107
  def decrypt(data)
108
- raise NoPrivateKeyError, "Private key file: #{@private_key_file}" unless private?
108
+ raise NoPrivateKeyError, "Private key file: #{private_key_file}" unless private?
109
109
 
110
110
  decrypted_data = Base64.decode64(data)
111
111
  private_rsa.private_decrypt(decrypted_data)
@@ -138,36 +138,36 @@ module PluginAWeek #:nodoc:
138
138
  end
139
139
 
140
140
  private
141
- def load_private_key
142
- @private_rsa = nil
141
+ def load_private_key
142
+ @private_rsa = nil
143
+
144
+ if private_key_file && File.file?(private_key_file)
145
+ @private_key = File.open(private_key_file) {|f| f.read}
146
+ end
147
+ end
143
148
 
144
- if @private_key_file && File.file?(@private_key_file)
145
- @private_key = File.open(@private_key_file) {|f| f.read}
149
+ def load_public_key
150
+ @public_rsa = nil
151
+
152
+ if public_key_file && File.file?(public_key_file)
153
+ @public_key = File.open(public_key_file) {|f| f.read}
154
+ end
146
155
  end
147
- end
148
-
149
- def load_public_key
150
- @public_rsa = nil
151
156
 
152
- if @public_key_file && File.file?(@public_key_file)
153
- @public_key = File.open(@public_key_file) {|f| f.read}
157
+ # Retrieves private RSA from the private key
158
+ def private_rsa
159
+ if key
160
+ private_key = @private_key.decrypt(:symmetric, :key => key, :algorithm => algorithm)
161
+ OpenSSL::PKey::RSA.new(private_key)
162
+ else
163
+ @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)
164
+ end
154
165
  end
155
- end
156
-
157
- # Retrieves private RSA from the private key
158
- def private_rsa
159
- if @key
160
- private_key = @private_key.decrypt(:symmetric, :key => @key, :algorithm => @algorithm)
161
- OpenSSL::PKey::RSA.new(private_key)
162
- else
163
- @private_rsa ||= OpenSSL::PKey::RSA.new(@private_key)
166
+
167
+ # Retrieves the public RSA
168
+ def public_rsa
169
+ @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)
164
170
  end
165
- end
166
-
167
- # Retrieves the public RSA
168
- def public_rsa
169
- @public_rsa ||= OpenSSL::PKey::RSA.new(@public_key)
170
- end
171
171
  end
172
172
  end
173
173
  end
@@ -25,7 +25,7 @@ module PluginAWeek #:nodoc:
25
25
  #
26
26
  # The following uses SHA mode to encrypt the string:
27
27
  #
28
- # password = "shhhh"
28
+ # password = 'shhhh'
29
29
  # password.encrypt # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
30
30
  #
31
31
  # == Custom encryption mode
@@ -33,8 +33,8 @@ module PluginAWeek #:nodoc:
33
33
  # The following uses Symmetric mode (with a default key) to encrypt the
34
34
  # string:
35
35
  #
36
- # PluginAWeek::EncryptedStrings::SymmetricEncryptor.default_key = "my_key"
37
- # password = "shhhh"
36
+ # PluginAWeek::EncryptedStrings::SymmetricEncryptor.default_key = 'my_key'
37
+ # password = 'shhhh'
38
38
  # password.encrypt(:symmetric) # => "jDACXI5hMPI=\n"
39
39
  #
40
40
  # == Custom encryption options
@@ -43,8 +43,8 @@ module PluginAWeek #:nodoc:
43
43
  # that determine how to encrypt the string. For example, SHA supports
44
44
  # a salt which seeds the algorithm:
45
45
  #
46
- # password = "shhhh"
47
- # password.encrypt(:sha, :salt => "secret") # => "3b22cbe4acde873c3efc82681096f3ae69aff828"
46
+ # password = 'shhhh'
47
+ # password.encrypt(:sha, :salt => 'secret') # => "3b22cbe4acde873c3efc82681096f3ae69aff828"
48
48
  def encrypt(*args)
49
49
  encryptor = encryptor_from_args(*args)
50
50
  encrypted_string = encryptor.encrypt(self)
@@ -57,10 +57,10 @@ module PluginAWeek #:nodoc:
57
57
  # takes the same parameters as #encrypt, but returns the same string
58
58
  # instead of a different one.
59
59
  #
60
- # For example,
60
+ # == Example
61
61
  #
62
- # password = "shhhh"
63
- # password.encrypt!(:symmetric, :key => "my_key") # => "jDACXI5hMPI=\n"
62
+ # password = 'shhhh'
63
+ # password.encrypt!(:symmetric, :key => 'my_key') # => "jDACXI5hMPI=\n"
64
64
  # password # => "jDACXI5hMPI=\n"
65
65
  def encrypt!(*args)
66
66
  encrypted_string = encrypt(*args)
@@ -72,9 +72,9 @@ module PluginAWeek #:nodoc:
72
72
  # Is this string encrypted? This will return true if the string is the
73
73
  # result of a call to #encrypt or #encrypt! was previously invoked.
74
74
  #
75
- # For example,
75
+ # == Example
76
76
  #
77
- # password = "shhhh"
77
+ # password = 'shhhh'
78
78
  # password.encrypted? # => false
79
79
  # password.encrypt! # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
80
80
  # password.encrypted? # => true
@@ -85,8 +85,13 @@ module PluginAWeek #:nodoc:
85
85
  # Decrypts this string. If this is not a string that was previously encrypted,
86
86
  # the encryption algorithm must be specified in the same way the
87
87
  # algorithm is specified when encrypting a string.
88
+ #
89
+ # == Example
90
+ #
91
+ # password = "jDACXI5hMPI=\n"
92
+ # password.decrypt(:symmetric, :key => 'my_key') # => "shhhh"
88
93
  def decrypt(*args)
89
- raise ArgumentError, "An encrypt algorithm must be specified since we can't figure it out" if args.empty? && !@encryptor
94
+ raise ArgumentError, "An encryption algorithm must be specified since we can't figure it out" if args.empty? && !@encryptor
90
95
 
91
96
  encryptor = args.any? ? encryptor_from_args(*args) : (@encryptor || encryptor_from_args(*args))
92
97
  encrypted_string = encryptor.decrypt(self)
@@ -102,7 +107,7 @@ module PluginAWeek #:nodoc:
102
107
  # For example,
103
108
  #
104
109
  # password = "jDACXI5hMPI=\n"
105
- # password.decrypt!(:symmetric, :key => "my_key") # => "shhhh"
110
+ # password.decrypt!(:symmetric, :key => 'my_key') # => "shhhh"
106
111
  # password # => "shhhh"
107
112
  def decrypt!(*args)
108
113
  replace(decrypt(*args))
@@ -122,55 +127,68 @@ module PluginAWeek #:nodoc:
122
127
  #
123
128
  # == Equality with strings
124
129
  #
125
- # password = "shhhh"
130
+ # password = 'shhhh'
126
131
  # password.encrypt! # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
127
132
  # password # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
128
133
  # password == "shhhh" # => true
129
134
  #
130
135
  # == Equality with encrypted strings
131
136
  #
132
- # password = "shhhh"
137
+ # password = 'shhhh'
133
138
  # password.encrypt! # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
134
139
  # password # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
135
- # password == "shhhh" # => true
140
+ # password == 'shhhh' # => true
136
141
  #
137
- # another_password = "shhhh"
142
+ # another_password = 'shhhh'
138
143
  # another_password.encrypt! # => "66c85d26dadde7e1db27e15a0776c921e27143bd"
139
144
  # password == another_password # => true
140
145
  def equals_with_encryption(other)
141
146
  if !(is_equal = equals_without_encryption(other)) && String === other
142
147
  if encrypted?
143
148
  if other.encrypted?
149
+ # We're both encrypted, so check if:
150
+ # (1) The other string is the encrypted value of this string
151
+ # (2) This string is the encrypted value of the other string
152
+ # (3) The other string is the encrypted value of this string, decrypted
153
+ # (4) This string is the encrypted value of the other string, decrypted
144
154
  is_string_equal?(self, other) || is_string_equal?(other, self) || self.can_decrypt? && is_string_equal?(self.decrypt, other) || other.can_decrypt? && is_string_equal?(other.decrypt, self)
145
155
  else
156
+ # Only we're encrypted
146
157
  is_string_equal?(other, self)
147
158
  end
148
159
  else
149
160
  if other.encrypted?
161
+ # Only the other string is encrypted
150
162
  is_string_equal?(self, other)
151
163
  else
164
+ # Neither are encrypted and equality test didn't work before, so
165
+ # they can't be equal
152
166
  false
153
167
  end
154
168
  end
155
169
  else
170
+ # The other value wasn't a string, so we can't check encryption equality
156
171
  is_equal
157
172
  end
158
173
  end
159
174
 
160
175
  private
161
- def is_string_equal?(value, encrypted_value) #:nodoc:
162
- if encrypted_value.can_decrypt?
163
- encrypted_value.decrypt.equals_without_encryption(value)
164
- else
165
- encrypted_value.equals_without_encryption(encrypted_value.encryptor.encrypt(value))
176
+ def is_string_equal?(value, encrypted_value) #:nodoc:
177
+ # If the encrypted value can be decrypted, then test against the decrypted value
178
+ if encrypted_value.can_decrypt?
179
+ encrypted_value.decrypt.equals_without_encryption(value)
180
+ else
181
+ # Otherwise encrypt this value based on the encryptor used on the encrypted value
182
+ # and test the equality of those strings
183
+ encrypted_value.equals_without_encryption(encrypted_value.encryptor.encrypt(value))
184
+ end
185
+ end
186
+
187
+ def encryptor_from_args(*args) #:nodoc:
188
+ options = args.last.is_a?(Hash) ? args.pop : {}
189
+ mode = (args.first || :sha).to_sym
190
+ "PluginAWeek::EncryptedStrings::#{mode.to_s.classify}Encryptor".constantize.new(options)
166
191
  end
167
- end
168
-
169
- def encryptor_from_args(*args) #:nodoc:
170
- options = args.last.is_a?(::Hash) ? args.pop : {}
171
- mode = (args.first || :sha).to_sym
172
- "PluginAWeek::EncryptedStrings::#{mode.to_s.classify}Encryptor".constantize.new(options)
173
- end
174
192
  end
175
193
  end
176
194
  end
@@ -35,7 +35,7 @@ module PluginAWeek #:nodoc:
35
35
  attr_accessor :salt
36
36
 
37
37
  # Configuration options:
38
- # * <tt>salt</tt> - Salt value to use for encryption
38
+ # * +salt+ - Salt value to use for encryption
39
39
  def initialize(options = {})
40
40
  options = options.symbolize_keys
41
41
  options.assert_valid_keys(:salt)
@@ -52,7 +52,7 @@ module PluginAWeek #:nodoc:
52
52
 
53
53
  # Returns the encrypted value of the data
54
54
  def encrypt(data)
55
- Digest::SHA1.hexdigest(data + @salt)
55
+ Digest::SHA1.hexdigest(data + salt)
56
56
  end
57
57
  end
58
58
  end
@@ -14,14 +14,14 @@ module PluginAWeek #:nodoc:
14
14
  # key must be specified. You can define the defaults for these values like
15
15
  # so:
16
16
  #
17
- # PluginAWeek::EncryptedStrings::SymmetricEncryptor.default_algorithm = "des-ecb"
18
- # PluginAWeek::EncryptedStrings::SymmetricEncryptor.default_key = "secret"
17
+ # PluginAWeek::EncryptedStrings::SymmetricEncryptor.default_algorithm = 'des-ecb'
18
+ # PluginAWeek::EncryptedStrings::SymmetricEncryptor.default_key = 'secret'
19
19
  #
20
20
  # If these configuration options are not passed in to #encrypt, then the
21
21
  # default values will be used. You can override the default values like so:
22
22
  #
23
- # password = "shhhh"
24
- # password.encrypt(:symmetic, :algorithm => "des-ecb", :key => "secret") # => "sUG6tYSn0mI=\n"
23
+ # password = 'shhhh'
24
+ # password.encrypt(:symmetric, :algorithm => 'des-ecb', :key => 'secret') # => "sUG6tYSn0mI=\n"
25
25
  #
26
26
  # An exception will be raised if no key is specified.
27
27
  #
@@ -35,7 +35,7 @@ module PluginAWeek #:nodoc:
35
35
  # default values will be used. You can override the default values like so:
36
36
  #
37
37
  # password = "sUG6tYSn0mI=\n"
38
- # password.decrypt(:symmetic, :algorithm => "des-ecb", :key => "secret") # => "shhhh"
38
+ # password.decrypt(:symmetric, :algorithm => 'des-ecb', :key => 'secret') # => "shhhh"
39
39
  #
40
40
  # An exception will be raised if no key is specified.
41
41
  class SymmetricEncryptor < Encryptor
@@ -51,8 +51,8 @@ module PluginAWeek #:nodoc:
51
51
  attr_accessor :key
52
52
 
53
53
  # Configuration options:
54
- # * <tt>key</tt> - Private key
55
- # * <tt>algorithm</tt> - Algorithm to use
54
+ # * +key+ - Private key
55
+ # * +algorithm+ - Algorithm to use
56
56
  def initialize(options = {})
57
57
  options = options.symbolize_keys
58
58
  options.assert_valid_keys(
@@ -62,24 +62,24 @@ module PluginAWeek #:nodoc:
62
62
  options.reverse_merge!(:key => @@default_key)
63
63
  options[:algorithm] ||= @@default_algorithm
64
64
 
65
- @key = options[:key]
66
- raise NoKeyError if @key.nil?
65
+ self.key = options[:key]
66
+ raise NoKeyError if key.nil?
67
67
 
68
- @algorithm = options[:algorithm]
68
+ self.algorithm = options[:algorithm]
69
69
 
70
70
  super()
71
71
  end
72
72
 
73
73
  # Decrypts the current string using the current key and algorithm specified
74
74
  def decrypt(data)
75
- cipher.decrypt(@key)
75
+ cipher.decrypt(key)
76
76
  decrypted_data = cipher.update(Base64.decode64(data))
77
77
  decrypted_data << cipher.final
78
78
  end
79
79
 
80
80
  # Encrypts the current string using the current key and algorithm specified
81
81
  def encrypt(data)
82
- cipher.encrypt(@key)
82
+ cipher.encrypt(key)
83
83
  encrypted_data = cipher.update(data)
84
84
  encrypted_data << cipher.final
85
85
 
@@ -87,9 +87,9 @@ module PluginAWeek #:nodoc:
87
87
  end
88
88
 
89
89
  private
90
- def cipher #:nodoc:
91
- @cipher ||= OpenSSL::Cipher::Cipher.new(@algorithm)
92
- end
90
+ def cipher #:nodoc:
91
+ @cipher ||= OpenSSL::Cipher::Cipher.new(algorithm)
92
+ end
93
93
  end
94
94
  end
95
95
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class AsymmetricEncryptorTest < Test::Unit::TestCase
4
4
  def setup
@@ -90,8 +90,8 @@ class AsymmetricEncryptorTest < Test::Unit::TestCase
90
90
  end
91
91
 
92
92
  private
93
- def set_default_key_files(public_key, private_key)
94
- PluginAWeek::EncryptedStrings::AsymmetricEncryptor.default_public_key_file = public_key
95
- PluginAWeek::EncryptedStrings::AsymmetricEncryptor.default_private_key_file = private_key
96
- end
93
+ def set_default_key_files(public_key, private_key)
94
+ PluginAWeek::EncryptedStrings::AsymmetricEncryptor.default_public_key_file = public_key
95
+ PluginAWeek::EncryptedStrings::AsymmetricEncryptor.default_private_key_file = private_key
96
+ end
97
97
  end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class EncryptorTest < Test::Unit::TestCase
4
4
  def setup
@@ -10,6 +10,6 @@ class EncryptorTest < Test::Unit::TestCase
10
10
  end
11
11
 
12
12
  def test_should_raise_exception_if_decrypt_not_implemented
13
- assert_raises(NotImplementedError) { @encryptor.decrypt('test') }
13
+ assert_raises(NotImplementedError) {@encryptor.decrypt('test')}
14
14
  end
15
- end
15
+ end
@@ -1,7 +1,7 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class NoKeyErrorTest < Test::Unit::TestCase
4
4
  def test_should_exist
5
5
  assert_not_nil PluginAWeek::EncryptedStrings::NoKeyError
6
6
  end
7
- end
7
+ end
@@ -1,7 +1,7 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class NoPrivateKeyErrorTest < Test::Unit::TestCase
4
4
  def test_should_exist
5
5
  assert_not_nil PluginAWeek::EncryptedStrings::NoPrivateKeyError
6
6
  end
7
- end
7
+ end
@@ -1,7 +1,7 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class NoPublicKeyErrorTest < Test::Unit::TestCase
4
4
  def test_should_exist
5
5
  assert_not_nil PluginAWeek::EncryptedStrings::NoPublicKeyError
6
6
  end
7
- end
7
+ end
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class ShaEncryptorTest < Test::Unit::TestCase
4
4
  def setup
@@ -18,6 +18,6 @@ class ShaEncryptorTest < Test::Unit::TestCase
18
18
  end
19
19
 
20
20
  def test_should_raise_exception_if_trying_to_decrypt
21
- assert_raises(NotImplementedError) { PluginAWeek::EncryptedStrings::ShaEncryptor.new.decrypt('test') }
21
+ assert_raises(NotImplementedError) {PluginAWeek::EncryptedStrings::ShaEncryptor.new.decrypt('test')}
22
22
  end
23
- end
23
+ end
data/test/string_test.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class EncryptedStringsTest < Test::Unit::TestCase
4
4
  def test_should_use_sha_for_default_encryption
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__), 'test_helper')
1
+ require File.dirname(__FILE__) + '/test_helper'
2
2
 
3
3
  class SymmetricallyEncryptedStringTest < Test::Unit::TestCase
4
4
  def setup
data/test/test_helper.rb CHANGED
@@ -1,6 +1,6 @@
1
- $:.unshift(File.dirname(__FILE__) + '/../lib')
2
-
3
- require 'rubygems'
4
1
  require 'test/unit'
2
+ require 'rubygems'
5
3
  require 'active_support'
6
- require "#{File.dirname(__FILE__)}/../init"
4
+
5
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
6
+ require File.dirname(__FILE__) + '/../init'
metadata CHANGED
@@ -1,82 +1,89 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.9.0
3
- specification_version: 1
4
2
  name: encrypted_strings
5
3
  version: !ruby/object:Gem::Version
6
- version: 0.0.3
7
- date: 2007-09-18 00:00:00 -04:00
8
- summary: Dead-simple string encryption/decryption syntax.
9
- require_paths:
10
- - lib
11
- email: info@pluginaweek.org
12
- homepage: http://www.pluginaweek.org
13
- rubyforge_project:
14
- description:
15
- autorequire: encrypted_strings
16
- default_executable:
17
- bindir: bin
18
- has_rdoc: true
19
- required_ruby_version: !ruby/object:Gem::Version::Requirement
20
- requirements:
21
- - - ">"
22
- - !ruby/object:Gem::Version
23
- version: 0.0.0
24
- version:
4
+ version: 0.0.4
25
5
  platform: ruby
26
- signing_key:
27
- cert_chain:
28
- post_install_message:
29
6
  authors:
30
- - Aaron Pfeifer, Neil Abraham
7
+ - Aaron Pfeifer
8
+ autorequire: encrypted_strings
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-05-05 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: aaron@pluginaweek.org
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
31
24
  files:
32
25
  - lib/encrypted_strings.rb
33
26
  - lib/encrypted_strings
34
- - lib/encrypted_strings/extensions
35
- - lib/encrypted_strings/asymmetric_encryptor.rb
36
- - lib/encrypted_strings/no_public_key_error.rb
27
+ - lib/encrypted_strings/no_private_key_error.rb
37
28
  - lib/encrypted_strings/no_key_error.rb
29
+ - lib/encrypted_strings/no_public_key_error.rb
30
+ - lib/encrypted_strings/asymmetric_encryptor.rb
31
+ - lib/encrypted_strings/symmetric_encryptor.rb
38
32
  - lib/encrypted_strings/sha_encryptor.rb
39
- - lib/encrypted_strings/no_private_key_error.rb
40
33
  - lib/encrypted_strings/encryptor.rb
41
- - lib/encrypted_strings/symmetric_encryptor.rb
34
+ - lib/encrypted_strings/extensions
42
35
  - lib/encrypted_strings/extensions/string.rb
43
- - test/test_helper.rb
44
- - test/no_private_key_error_test.rb
45
- - test/no_public_key_error_test.rb
46
- - test/sha_encryptor_test.rb
47
- - test/symmetric_encryptor_test.rb
48
- - test/string_test.rb
49
- - test/encryptor_test.rb
50
- - test/asymmetric_encryptor_test.rb
51
36
  - test/keys
52
- - test/no_key_error_test.rb
53
37
  - test/keys/private
38
+ - test/keys/encrypted_private
54
39
  - test/keys/public
55
40
  - test/keys/encrypted_public
56
- - test/keys/encrypted_private
41
+ - test/no_private_key_error_test.rb
42
+ - test/encryptor_test.rb
43
+ - test/asymmetric_encryptor_test.rb
44
+ - test/no_key_error_test.rb
45
+ - test/sha_encryptor_test.rb
46
+ - test/test_helper.rb
47
+ - test/no_public_key_error_test.rb
48
+ - test/string_test.rb
49
+ - test/symmetric_encryptor_test.rb
57
50
  - CHANGELOG
58
51
  - init.rb
59
52
  - MIT-LICENSE
60
53
  - Rakefile
61
54
  - README
55
+ has_rdoc: true
56
+ homepage: http://www.pluginaweek.org
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ version:
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ requirements: []
75
+
76
+ rubyforge_project:
77
+ rubygems_version: 1.1.0
78
+ signing_key:
79
+ specification_version: 2
80
+ summary: Dead-simple string encryption/decryption syntax.
62
81
  test_files:
63
82
  - test/no_private_key_error_test.rb
64
- - test/no_public_key_error_test.rb
65
- - test/sha_encryptor_test.rb
66
- - test/symmetric_encryptor_test.rb
67
- - test/string_test.rb
68
83
  - test/encryptor_test.rb
69
84
  - test/asymmetric_encryptor_test.rb
70
85
  - test/no_key_error_test.rb
71
- rdoc_options: []
72
-
73
- extra_rdoc_files: []
74
-
75
- executables: []
76
-
77
- extensions: []
78
-
79
- requirements: []
80
-
81
- dependencies: []
82
-
86
+ - test/sha_encryptor_test.rb
87
+ - test/no_public_key_error_test.rb
88
+ - test/string_test.rb
89
+ - test/symmetric_encryptor_test.rb