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#random_key

cipher.random_key → key

Generate a random key 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 #random_iv #reset #pkcs5_keyivgen #update also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0