lib/fernet/encryption.rb in fernet-2.1 vs lib/fernet/encryption.rb in fernet-2.1.1

- old
+ new

@@ -24,10 +24,15 @@ cipher = OpenSSL::Cipher.new('AES-128-CBC') cipher.encrypt iv = opts[:iv] || cipher.random_iv cipher.iv = iv cipher.key = opts[:key] - [cipher.update(opts[:message]) + cipher.final, iv] + ciphertext = "" + if opts[:message] && !opts[:message].empty? + ciphertext += cipher.update(opts[:message]) + end + ciphertext += cipher.final + [ciphertext, iv] end # Internal: Decrypts the provided ciphertext using a AES-128-CBC cipher with a # the provided IV and encryption key #