LoginSignup
0
0

More than 3 years have passed since last update.

個人メモ: ランダムな何かを生成する Ruby ワンライナー

Posted at

個人的に必要になるけど、よく忘れるのでメモ

13桁のランダムな数字 (ただし、先頭は常に 1)

ruby -e "puts('1' + (1..12).map { ('0'..'9').to_a.sample }.join)"

20 バイトのランダムなバイト列 (hexadecimal 形式)

ruby -r securerandom -e 'puts SecureRandom.hex(20)'
0
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0