LoginSignup
0
4

More than 5 years have passed since last update.

Python3でランダムなパスワードを生成する(サンプル)

Last updated at Posted at 2017-03-14

Python3でランダムなパスワードを生成するサンプルです。

10文字の長さのランダムなパスワードを生成します。

randompwd.py
#!/usr/bin/env python3

from random import randint
#パスワードに利用する文字の一覧
chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/!$%&'()=~|@`[]{}*+<>?_;:,.\\"

len = len(chars)
#パスワードの長さはとりあえず10文字
for i in range(0, 10):
  pos = randint(0,len-1)
  print (chars[pos], end="")

Ruby版のサンプルはこちら

0
4
4

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
4