| | Comments (0) | TrackBacks (0)

import random, crypt
import sys

# とりあえず64文字のsaltの種を用意
saltSet = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',

# Randomクラスのインスタンスを生成
r = random.Random()

# saltを作成
salt = str(saltSet[r.randint(0, 63)]) + str(saltSet[r.randint(0, 63)])

# 引数があればcrypt
if len(sys.argv) > 1:
  print crypt.crypt(sys.argv[1], salt)


0 TrackBacks

Listed below are links to blogs that reference this entry: Pythonでhtpasswd実装のメモを残してみる.

TrackBack URL for this entry:

Leave a comment

About this Entry

This page contains a single entry by Takeshi SAKURAI published on February 10, 2009 6:53 PM.

TwistedでCGIの動くWebサーバを書いてみる、にBasic認証機能を追加してみる was the previous entry in this blog.

vim上でpythonコードをデバッグする is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.