Project

General

Profile

Actions

Feature #18817

closed

SecureRandom::choose is not being exposed

Added by midnight (Sarun R) over 2 years ago. Updated over 2 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:108773]

Description

I read through the doc of SecureRandom and found that it has the choose method.
So, I spin up irb for a quick test.

> ::SecureRandom.choose([*('0'..'9'), *('A'..'Z')], 25)
(irb):47:in `<main>': private method `choose' called for SecureRandom:Module (NoMethodError)
                                                                                                            
::SecureRandom.choose([*('0'..'9'), *('A'..'Z')], 25)                                                       
              ^^^^^^^

The method is marked as private. So, I forcefully call the method with success.

> ::SecureRandom.send(:choose, [*('0'..'9'), *('A'..'Z')], 25)
=> "5FHY5PXLT184GIVISCVESTMGO"

I did not test for uniformity of the randomness, though.

I wonder why the method has been marked as private?
Is it not ready for production uses?


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #18183: make SecureRandom.choose publicClosednobu (Nobuyoshi Nakada)Actions
Actions #1

Updated by mame (Yusuke Endoh) over 2 years ago

  • Is duplicate of Feature #18183: make SecureRandom.choose public added

Updated by mame (Yusuke Endoh) over 2 years ago

  • Status changed from Open to Rejected

"choose" is named just for an internal API. We need another good name if we make it public. Continue to discuss in #18183.

Actions

Also available in: Atom PDF

Like0
Like0Like0