From: "p8 (Petrik de Heus) via ruby-core" Date: 2023-08-28T19:28:38+00:00 Subject: [ruby-core:114569] [Ruby master Feature#19854] Make SecureRandom.choose public Issue #19854 has been reported by p8 (Petrik de Heus). ---------------------------------------- Feature #19854: Make SecureRandom.choose public https://bugs.ruby-lang.org/issues/19854 * Author: p8 (Petrik de Heus) * Status: Open * Priority: Normal ---------------------------------------- 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: ```ruby 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 -- https://bugs.ruby-lang.org/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/postorius/lists/ruby-core.ml.ruby-lang.org/