<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/encrypted_strings/active_record/encrypts.rb</filename>
    </added>
    <added>
      <filename>lib/encrypted_strings/core_ext/asymmetrically_encrypted_string.rb</filename>
    </added>
    <added>
      <filename>lib/encrypted_strings/core_ext/encrypted_string.rb</filename>
    </added>
    <added>
      <filename>lib/encrypted_strings/core_ext/sha_encrypted_string.rb</filename>
    </added>
    <added>
      <filename>lib/encrypted_strings/core_ext/symmetrically_encrypted_string.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,5 +1 @@
-require 'encrypted_strings'
-
-class ::Integer #:nodoc:
-  include PluginAWeek::CoreExtensions::String::EncryptedStrings
-end
\ No newline at end of file
+require 'encrypted_strings'
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -22,10 +22,12 @@
 require 'openssl'
 require 'base64'
 
-require File.join('encrypted_strings', 'encrypted_string')
-require File.join('encrypted_strings', 'symmetrically_encrypted_string')
-require File.join('encrypted_strings', 'asymmetrically_encrypted_string')
-require File.join('encrypted_strings', 'sha_encrypted_string')
+require File.join('encrypted_strings', 'core_ext', 'encrypted_string')
+require File.join('encrypted_strings', 'core_ext', 'symmetrically_encrypted_string')
+require File.join('encrypted_strings', 'core_ext', 'asymmetrically_encrypted_string')
+require File.join('encrypted_strings', 'core_ext', 'sha_encrypted_string')
+
+require File.join('encrypted_strings', 'active_record', 'encrypts')
 
 class NoKeyError &lt; StandardError
 end
@@ -40,71 +42,59 @@ module PluginAWeek #:nodoc:
   module CoreExtensions #:nodoc:
     module String #:nodoc:
       module EncryptedStrings
+        def self.included(base) #:nodoc:
+          base.class_eval do
+            alias_method :equals_without_encryption, :==
+            alias_method :==, :equals_with_encryption
+          end
+        end
+        
         #
         #
-        def encrypt(mode = :sha, options = {})
-          options[:encrypt] = true
+        def encrypt(*args)
+          options = args.last.is_a?(::Hash) ? args.pop : {}
+          mode = (args.first || :sha).to_sym
           
-          case mode
-            when :sha
-              SHAEncryptedString.new(self, options)
-            when :asymmetric, :asymmetrical
-              AsymmetricallyEncryptedString(self, options)
-            when :symmetric, :symmetrical
-              SymmetricallyEncryptedString.new(self, options)
-            else
-              raise ArgumentError, &quot;Invalid encryption mode: #{mode}&quot;
-          end
+          send(&quot;encrypt_#{mode}&quot;, options)
+        end
+        
+        def encrypt_sha(options = {})
+          create_encrypted_string(SHAEncryptedString, options)
         end
-      end
-    end
-  end
-  
-  module Encrypts #:nodoc:
-    def self.included(base) #:nodoc:
-      base.extend(MacroMethods)
-    end
-    
-    module MacroMethods
-      #
-      #
-      def encrypts(attr_name, options = {})
-        options.reverse_merge!(
-          :mode =&gt; :sha
-        )
         
-        klass = case options.delete(:mode)
-          when :sha
-            SHAEncryptedString
-          when :asymmetric, :asymmetrically
-            AsymmetricallyEncryptedString
-          when :symmetric, :symmetrically
-            SymmetricallyEncryptedString
+        #
+        #
+        def encrypt_asymmetrically(options = {})
+          create_encrypted_string(AsymmetricallyEncryptedString, options)
         end
+        alias_method :encrypt_asymmetric, :encrypt_asymmetrically
         
-        var_name = &quot;@#{attr_name}&quot;
+        #
+        #
+        def encrypt_symmetrically(options = {})
+          create_encrypted_string(SymmetricallyEncryptedString, options)
+        end
+        alias_method :encrypt_symmetric, :encrypt_symmetrically
         
-        # Define the reader
-        reader_options = options.dup
-        reader_options[:encrypt] = false
-        define_method(attr_name) do
-          if (data = read_attribute(attr_name)) &amp;&amp; !data.is_a?(klass)
-            data = instance_variable_get(var_name) || instance_variable_set(var_name, klass.new(data, reader_options))
+        #
+        #
+        def equals_with_encryption(other)
+          if other.is_a?(EncryptedString) &amp;&amp; self.class == ::String
+            other == self
+          else
+            equals_without_encryption(other)
           end
-          
-          data
         end
         
-        # Define the writer
-        define_method(&quot;#{attr_name}=&quot;) do |data|
-          unless data.is_a?(EncryptedString)
-            data = klass.new(data, options)
-          end
-          
-          write_attribute(attr_name, data)
-          instance_variable_set(var_name, klass.new(data, options))
+        private
+        def create_encrypted_string(klass, options) #:nodoc:
+          klass.new(self, options)
         end
       end
     end
   end
 end
+
+::String.class_eval do
+  include PluginAWeek::CoreExtensions::String::EncryptedStrings
+end
\ No newline at end of file</diff>
      <filename>lib/encrypted_strings.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,4 +1,4 @@
-require 'sentry'
+#require 'sentry'
 
 desc &quot;Creates a private/public key for asymmetric encryption:  rake sentry_key PUB=/path/to/public.key PRIV=/path/to/priv.key [KEY=secret]&quot;
 task :encryption_key do</diff>
      <filename>tasks/encrypted_strings.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/encrypted_strings/asymmetrically_encrypted_string.rb</filename>
    </removed>
    <removed>
      <filename>lib/encrypted_strings/encrypted_string.rb</filename>
    </removed>
    <removed>
      <filename>lib/encrypted_strings/sentry.rb</filename>
    </removed>
    <removed>
      <filename>lib/encrypted_strings/sha_encrypted_string.rb</filename>
    </removed>
    <removed>
      <filename>lib/encrypted_strings/symmetrically_encrypted_string.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>48a2ff0fc77cc66270df852502395b53d3f04c40</id>
    </parent>
  </parents>
  <author>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </author>
  <url>http://github.com/pluginaweek/encrypted_strings/commit/4de5055dd02c1dcb75120415e1fda34ee618c230</url>
  <id>4de5055dd02c1dcb75120415e1fda34ee618c230</id>
  <committed-date>2006-10-25T18:19:47-07:00</committed-date>
  <authored-date>2006-10-25T18:19:47-07:00</authored-date>
  <message>Refactored determination of the encryption mode to more easily allow for extensions by other developers.
Added support for dynamic creation of the salt for an sha-encrypted string.
Encrypted strings for ActiveRecord are now stored in an attribute called crypted_* (where * is the name of the actual attribute).
Encrypted strings are now only generated immediately before validation rather than immediately upon assignment of the actual attribute.
Moved some of the initialization code out of init.rb.
Continued moving some code over to the new framework from the original sentry plugin.</message>
  <tree>b13e689abb669b8c5910259b6b348c5a3f153ac0</tree>
  <committer>
    <name>Aaron Pfeifer</name>
    <email>aaron.pfeifer@gmail.com</email>
  </committer>
</commit>
