📜  红宝石 |随机 random_bytes()函数

📅  最后修改于: 2022-05-13 01:54:58.335000             🧑  作者: Mango

红宝石 |随机 random_bytes()函数

Random#random_bytes() :random_bytes()是一个 Random 类方法,它返回一个随机 random_binary字符串。

示例 #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