When a record is loaded is it decrypted. If the plaintext has not changed, this sets the value back to previously encrypted string. If we did not do this it would be re-encrypted since it is decrypted at that point.  

--  
Justin Mazzi


On Monday, March 18, 2013 at 8:40 AM, Fabio Kreusch wrote:

> In lib/crypt_keeper/model.rb:
> > # Private: Encrypt each crypt_keeper_fields > def encrypt_callback > crypt_keeper_fields.each do |field| > if !self[field].nil? > - self[field] = self.class.encrypt read_attribute(field) > + if plaintext_changed?(field) > + self[field] = self.class.encrypt read_attribute(field) > + else > + self[field] = crypt_keeper_dirty_tracking[field]  
> Why do we need to assign in case it has not changed?
>  
> —
> Reply to this email directly or view it on GitHub (https://github.com/jmazzi/crypt_keeper/pull/33/files#r3411115).
>  
>  
>