diff --git a/lib/ably/util/crypto.rb b/lib/ably/util/crypto.rb index 3635b59a5..7707af93e 100644 --- a/lib/ably/util/crypto.rb +++ b/lib/ably/util/crypto.rb @@ -83,8 +83,8 @@ def encrypt(payload, encrypt_options = {}) 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