本文簡要介紹ruby語言中 Random::Formatter.random_bytes
的用法。
用法
random_bytes(n=nil)
Random::Formatter#random_bytes
生成隨機二進製字符串。
參數n
指定結果字符串的長度。
如果 n
未指定或為零,則假定為 16。未來可能會更大。
結果可能包含任何字節:“x00” - “xff”。
require 'random/formatter'
prng.random_bytes #=> "\xD8\\\xE0\xF4\r\xB2\xFC*WM\xFF\x83\x18\xF45\xB6"
prng.random_bytes #=> "m\xDC\xFC/\a\x00Uf\xB2\xB2P\xBD\xFF6S\x97"
相關用法
- Ruby Formatter.urlsafe_base64用法及代碼示例
- Ruby Formatter.uuid用法及代碼示例
- Ruby Formatter.base64用法及代碼示例
- Ruby Formatter.hex用法及代碼示例
- Ruby Formatter.alphanumeric用法及代碼示例
- Ruby Formatter.choose用法及代碼示例
- Ruby Formatter模塊用法及代碼示例
- Ruby Float arg()用法及代碼示例
- Ruby File.identical?用法及代碼示例
- Ruby Fiber.schedule用法及代碼示例
- Ruby Float fdiv()用法及代碼示例
- Ruby Float quo()用法及代碼示例
- Ruby Float angle()用法及代碼示例
- Ruby FileUtils.mkdir用法及代碼示例
- Ruby Float divmod()用法及代碼示例
- Ruby Float.self - other用法及代碼示例
- Ruby Float.rationalize用法及代碼示例
- Ruby Float.truncate用法及代碼示例
- Ruby FileUtils.compare_file用法及代碼示例
- Ruby FileUtils.options_of用法及代碼示例
- Ruby File.dirname用法及代碼示例
- Ruby Float prev_float()用法及代碼示例
- Ruby FileUtils.ln_s用法及代碼示例
- Ruby Float round()用法及代碼示例
- Ruby Float denominator()用法及代碼示例
注:本文由純淨天空篩選整理自ruby-lang.org大神的英文原創作品 Formatter.random_bytes。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。