Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.0.pre - unable to use AES encryptor with AR object when field is nil or empty-string #34

Closed
Capncavedan opened this issue Apr 3, 2013 · 1 comment

Comments

@Capncavedan
Copy link
Contributor

I gave 0.9.0.pre a test run yesterday, and found a change in behavior from 0.8.0 in that it throws an exception when attempting to save an AR object where the crypt_keeper field is nil.

I'd previously noticed a problem with AR objects and empty strings.

Researching AES just a little bit, it seems AES cannot encrypt an empty string. I'm not sure how other projects/libraries handle it (mysql AES encryption for example works on an empty string).

I suggest we modify the AES encryptor to return nils and empty-strings as-is, like so:

      # Public: Decrypt a string
      #
      # Returns a string
      def decrypt(value)
        return nil if value.nil?
        return '' if value == ''
        ...
      end


      # Public: Encrypt a string
      #
      # Returns a string
      def encrypt(value)
        return nil if value.nil?
        return '' if value == ''
        ...
      end

I'm happy to submit a pull request for this if you agree this should happen.

@jmazzi
Copy link
Owner

jmazzi commented Apr 11, 2013

closed by #35

@jmazzi jmazzi closed this as completed Apr 11, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants