Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

OpenSSL::Cipher#iv=

cipher.iv = string → string

Sets the cipher IV. Please note that since you should never be using ECB mode, an IV is always explicitly required and should be set prior to encryption. The IV itself can be safely transmitted in public, but it should be unpredictable to prevent certain kinds of attacks. You may use Cipher#random_iv to create a secure random IV.

Only call this method after calling Cipher#encrypt or Cipher#decrypt.

See also #initialize_copy #iv_len #final #iv_len= also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0