LoginSignup
8
7

More than 5 years have passed since last update.

パスワードを作るワンライナー

Posted at

ワンライナー

ruby -e 'puts Array.new((ARGV[0] || 32).to_i){ rand(62) }.pack(%q!C*!).tr(%Q!\x00-\x3e!, %q!A-Za-z0-9!)'

実行結果

% ruby -e 'puts Array.new((ARGV[0] || 32).to_i){ rand(62) }.pack(%q!C*!).tr(%Q!\x00-\x3e!, %q!A-Za-z0-9!)'
DZjADuaVlU9kCKDwex1yZoyPi0TysMfT

.zshrcへ追加

alias pw="ruby -e 'puts Array.new((ARGV[0] || 32).to_i){ rand(62) }.pack(%q!C*!).tr(%Q!\x00-\x3e!, %q!A-Za-z0-9!)'"

zsh経由で使う

% pw 16
SKZUBmGLAULN33IC
% pw 32
5mit4kh5iyKDiZddd3DkLyFhPuCf0DnQ
% pw 64
2R956EM9Sd08lVXYTkTlwlBECudScOitmw9Q6yC0qV8eXTfi4FmmHNS1xsPCAzWY

8
7
0

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
8
7