Skip to content

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

class method

OpenSSL::BN.generate_prime

BN.generate_prime(bits, [, safe [, add [, rem]]]) => bn

Generates a random prime number of bit length bits. If safe is set to true, generates a safe prime. If add is specified, generates a prime that fulfills condition p % add = rem.

Parameters

  • bits - integer

  • safe - boolean

  • add - BN

  • rem - BN

See also .new .rand also in 4.1 · 4.0 · 3.4 · 3.3 · 3.1 · 3.0