Ruby 2.7.0 リファレンスマニュアル > ライブラリ一覧 > securerandomライブラリ > SecureRandomモジュール > alphanumeric
alphanumeric(n = nil) -> String
[permalink][rdoc]ランダムな英数字を生成して返します。
require 'securerandom'
p SecureRandom.alphanumeric #=> "2BuBuLf3WfSKyQbR"
p SecureRandom.alphanumeric(10) #=> "i6K93NdqiH"