Skip to content

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

class method

OpenSSL::PKey::DH.generate

DH.generate(size [, generator]) → dh

Creates a new DH instance from scratch by generating the private and public components alike.

Parameters

  • size is an integer representing the desired key size. Keys smaller than 1024 bits should be considered insecure.

  • generator is a small number > 1, typically 2 or 5.

See also .new #compute_key also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1