Project

General

Profile

Actions

Feature #19854

closed

Make SecureRandom.choose public

Added by p8 (Petrik de Heus) about 1 year ago. Updated about 1 year ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:114569]

Description

SecureRandom implements the choose method that randomly draws from a source array of characters.
This method is currently private, but it could be useful as a public method.

For example for generating a pin number:

SecureRandom.choose((0..9).to_a, 6)

Another example is Rails, which implements SecureRandom.base36 and SecureRandom.base58.
These implementations would be a lot simpler (and faster for base36) by replacing it with choose:
https://github.com/rails/rails/blob/735cba5bed7a54c7397dfeec1bed16033ae286f8/activesupport/lib/active_support/core_ext/securerandom.rb


Related issues 1 (0 open1 closed)

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

Also available in: Atom PDF

Like0
Like0Like0