Ruby Random random_bytes()函数
Random#random_bytes() : random_bytes() 是一个Random类方法,用于返回一个随机的二进制字符串。
语法。Random.random_bytes()
参数。随机值
返回:一个随机的随机二进制字符串。
例子 #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