-
Notifications
You must be signed in to change notification settings - Fork 99
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
Exception occurs with empty string #31
Comments
@Capncavedan which encryptor are you using? |
The default AES encryptor, like so:
|
One option I can think of is creating a "strict" mode for the AES encryptor, and others really. That would be the default mode. In strict mode, you would receive errors for nil or empty values, like you currently do. In non strict mode:
the original value you would be returned for nil or empty strings for decrypt and encrypt. It would look something like this: def encrypt(value)
if value.blank? && strict_mode
value
else
# encryption
end
end
def decrypt(value)
if value.blank? && strict_mode
value
else
# decryption
end
end How do you feel about creating a pull request to do that? |
@Capncavedan let me know what you think about that. |
I think that sounds pretty good, @jmazzi. I'll work on a pull request. Note that nil and non-empty strings, e.g. " ", don't generate problems with AES, at least in my experience so far. Just the empty string. |
Hmm, well I'm not sure that's a issue with crypt_keeper then. Non empty strings have a value. On Friday, March 8, 2013 at 5:07 PM, Dan Buettner wrote:
|
closed by #35 |
When saving a record where an encrypted field has a value of "" (empty string), as is common when a web form field is left blank, crypt_keeper raises an exception.
I've worked around it by setting the field to nil if it == "" in the controller but this is inelegant for sure.
Is there a cleaner workaround I'm not aware of?
Thanks,
-Dan
The text was updated successfully, but these errors were encountered: