Blank strings are not encryptable in many encryption implementations. Example:  

irb(main):006:0> a=CryptKeeper::Provider::Aes.new(key: 'test')
=> #<CryptKeeper::Provider::Aes:0x007fe5599346a8 @aes=#<OpenSSL::Cipher::Cipher:0x007fe559934658>, @key="\x9F\x86\xD0\x81\x88L}e\x9A/\xEA\xA0\xC5Z\xD0\x15\xA3\xBFO\e+\v\x82,\xD1]l\x15\xB0\xF0\n\b">
irb(main):007:0> a.encrypt('')
ArgumentError: data must not be empty



--  
Justin Mazzi


On Friday, October 18, 2013 at 3:08 PM, Fabio Kreusch wrote:

> In spec/model_spec.rb:
> > @@ -66,6 +66,28 @@ module CryptKeeper > record = SensitiveData.create!(storage: 'testing') > SensitiveData.find(record).storage.should == 'testing' > end > + > + it "does not encrypt nil" do > + CryptKeeper::Provider::Encryptor.any_instance.should_not_receive(:encrypt) > + SensitiveData.create!(storage: nil) > + end > + > + it "does not encrypt empty strings" do > + CryptKeeper::Provider::Encryptor.any_instance.should_not_receive(:encrypt) > + SensitiveData.create!(storage: "")  
> For blank strings, would it store nil? I'm thinking that the only situation in which we would not want to encrypt is nil, other values should be encrypted, even blanks, otherwise we might have unexpected results?
>  
> —
> Reply to this email directly or view it on GitHub (https://github.com/jmazzi/crypt_keeper/pull/57/files#r7071127).
>  
>  
>