LoginSignup
0

More than 3 years have passed since last update.

posted at

Organization

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

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

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)'

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
What you can do with signing up
0