使用 Ruby 语言的 SecureRandom。require 'securerandom' randomstring = SecureRandom.hex(5) 它会生成n*2个包含“0-9”和“a-f”的随机字符串