<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,3 +1,6 @@
+2009-01-18 - Sean Huber (shuber@huberry.com)
+  * Don't attempt to encrypt/decrypt empty strings
+
 2009-01-14 - Sean Huber (shuber@huberry.com)
   * Move Class logic into Object
 </diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,6 @@
 Gem::Specification.new do |s| 
   s.name    = 'attr_encrypted'
-  s.version = '1.0.7'
+  s.version = '1.0.8'
   s.date    = '2009-01-13'
   
   s.summary     = 'Generates attr_accessors that encrypt and decrypt attributes transparently'</diff>
      <filename>attr_encrypted.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -152,8 +152,8 @@ module Huberry
           
           define_class_method &quot;encrypt_#{attribute}&quot; do |value|
             if options[:if] &amp;&amp; !options[:unless]
-              if value.nil?
-                encrypted_value = nil
+              if value.nil? || (value.is_a?(String) &amp;&amp; value.empty?)
+                encrypted_value = value
               else
                 value = Marshal.dump(value) if options[:marshal]
                 encrypted_value = options[:encryptor].send options[:encrypt_method], options.merge(:value =&gt; value)
@@ -167,8 +167,8 @@ module Huberry
           
           define_class_method &quot;decrypt_#{attribute}&quot; do |encrypted_value|
             if options[:if] &amp;&amp; !options[:unless]
-              if encrypted_value.nil?
-                decrypted_value = nil
+              if encrypted_value.nil? || (encrypted_value.is_a?(String) &amp;&amp; encrypted_value.empty?)
+                decrypted_value = encrypted_value
               else
                 encrypted_value = encrypted_value.unpack(options[:encode]).to_s if options[:encode]
                 decrypted_value = options[:encryptor].send(options[:decrypt_method], options.merge(:value =&gt; encrypted_value))</diff>
      <filename>lib/attr_encrypted.rb</filename>
    </modified>
    <modified>
      <diff>@@ -75,6 +75,10 @@ class AttrEncryptedTest &lt; Test::Unit::TestCase
     assert_nil User.encrypt_email(nil)
   end
   
+  def test_should_not_encrypt_empty_string
+    assert_equal '', User.encrypt_email('')
+  end
+  
   def test_should_encrypt_email
     assert_not_nil User.encrypt_email('test@example.com')
     assert_not_equal 'test@example.com', User.encrypt_email('test@example.com')
@@ -92,6 +96,10 @@ class AttrEncryptedTest &lt; Test::Unit::TestCase
     assert_nil User.decrypt_email(nil)
   end
   
+  def test_should_not_decrypt_empty_string
+    assert_equal '', User.decrypt_email('')
+  end
+  
   def test_should_decrypt_email
     encrypted_email = User.encrypt_email('test@example.com')
     assert_not_equal 'test@test.com', encrypted_email</diff>
      <filename>test/attr_encrypted_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>bcfafe5781de797d8d91013f021e3baf7712c89e</id>
    </parent>
  </parents>
  <author>
    <name>Sean Huber</name>
    <email>shuber@huberry.com</email>
  </author>
  <url>http://github.com/shuber/attr_encrypted/commit/b0a701f208b5f34dde475841e7b9d687fa1113ec</url>
  <id>b0a701f208b5f34dde475841e7b9d687fa1113ec</id>
  <committed-date>2009-01-18T15:02:55-08:00</committed-date>
  <authored-date>2009-01-18T15:02:55-08:00</authored-date>
  <message>Don't attempt to encrypt/decrypt empty strings</message>
  <tree>d7230b5acdd5f4bd28eedd629a7c1309f01a06c6</tree>
  <committer>
    <name>Sean Huber</name>
    <email>shuber@huberry.com</email>
  </committer>
</commit>
