红宝石 |随机 random_bytes()函数
Random#random_bytes() :random_bytes()是一个 Random 类方法,它返回一个随机 random_binary字符串。
Syntax: Random.random_bytes()
Parameter: Random values
Return: a random random_binary string.
示例 #1:
# Ruby code for Random.random_bytes() method
# loading library
require 'securerandom'
# declaring Random value
date_a = SecureRandom.random_bytes
# declaring Random value
date_b = SecureRandom.random_bytes
# random_bytes value
puts "Random random_bytes form : #{date_a}\n\n"
puts "Random random_bytes form : #{date_b}\n\n"
输出 :
Random random_bytes form : ?? ?Y?[?c5???,
Random random_bytes form : aG]???6, ??t?;A;p
示例 #2:
# Ruby code for Random.random_bytes() method
# loading library
require 'securerandom'
# declaring Random value
date_a = SecureRandom.random_bytes
# declaring Random value
date_b = SecureRandom.random_bytes
# random_bytes value
puts "Random random_bytes form : #{date_a}\n\n"
puts "Random random_bytes form : #{date_b}\n\n"
输出 :
Random random_bytes form : ?????~x?2??&D?w
Random random_bytes form : ?f??o?F??z/??h