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#random_iv
cipher.random_iv → iv
ext/openssl/lib/openssl/cipher.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.2.0/ext/openssl/lib/openssl/cipher.rb, line 55
def random_iv
str = OpenSSL::Random.random_bytes(self.iv_len)
self.iv = str
end
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.