File tree Expand file tree Collapse file tree 1 file changed +2
-6
lines changed
activesupport/lib/active_support/core_ext Expand file tree Collapse file tree 1 file changed +2
-6
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ module SecureRandom
17
17
# p SecureRandom.base58 # => "4kUgL2pdQMSCQtjE"
18
18
# p SecureRandom.base58(24) # => "77TMHrHJFvFDwodq8w7Ev2m7"
19
19
def self . base58 ( n = 16 )
20
- SecureRandom . alphanumeric ( n , chars : BASE58_ALPHABET )
20
+ alphanumeric ( n , chars : BASE58_ALPHABET )
21
21
end
22
22
23
23
# SecureRandom.base36 generates a random base36 string in lowercase.
@@ -32,10 +32,6 @@ def self.base58(n = 16)
32
32
# p SecureRandom.base36 # => "4kugl2pdqmscqtje"
33
33
# p SecureRandom.base36(24) # => "77tmhrhjfvfdwodq8w7ev2m7"
34
34
def self . base36 ( n = 16 )
35
- SecureRandom . random_bytes ( n ) . unpack ( "C*" ) . map do |byte |
36
- idx = byte % 64
37
- idx = SecureRandom . random_number ( 36 ) if idx >= 36
38
- BASE36_ALPHABET [ idx ]
39
- end . join
35
+ alphanumeric ( n , chars : BASE36_ALPHABET )
40
36
end
41
37
end
You can’t perform that action at this time.
0 commit comments