Skip to content

Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →

instance method

OpenSSL::Cipher#random_iv

cipher.random_iv → iv

Generate a random IV with OpenSSL::Random.random_bytes and sets it to the cipher, and returns it.

You must call encrypt or decrypt before calling this method.

See also #pkcs5_keyivgen #random_key #padding= #reset also in 4.1 · 4.0 · 3.4 · 3.2 · 3.1 · 3.0