lib/ably/util/crypto.rb in ably-1.2.4 vs lib/ably/util/crypto.rb in ably-1.2.6
- old
+ new
@@ -81,11 +81,11 @@
cipher = openssl_cipher
cipher.encrypt
cipher.key = key
iv = encrypt_options[:iv] || fixed_iv || cipher.random_iv
cipher.iv = iv
-
- iv << cipher.update(payload) << cipher.final
+ iv << cipher.update(payload) unless payload.empty?
+ iv << cipher.final
end
# Decrypt payload using configured Cipher
#
# @param [String] encrypted_payload_with_iv the encrypted payload to be decrypted