Method: AuthingRuby::Utils.generateRandomString
- Defined in:
- lib/authing_ruby/utils/utils.rb
.generateRandomString(length = 30) ⇒ Object
生成随机字符串,参照 JS SDK 里的 src/lib/utils.ts
21 22 23 24 25 26 27 28 29 |
# File 'lib/authing_ruby/utils/utils.rb', line 21 def self.generateRandomString(length = 30) result = "" chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' for i in 0..length-1 random_index = rand(0..chars.length-1) result += chars[random_index] end return result end |