irb(main):001> require 'securerandom'
=> true
irb(main):002> SecureRandom.random_number 99999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999
=> 11380843988461997519060872897600760284169284164389388149303923753279158276261635029646581640774720711699958031921860
It's not prime though, so it's not suitable as a key. For that, you'd want to use OpenSSL::BN.generate_prime