From: Vincent Le Gallic Date: Sun, 29 Sep 2013 16:59:17 +0000 (+0200) Subject: Parce que hasher à la main, c'est trop mainstream. X-Git-Url: http://gitweb.pimeys.fr/?p=scripts-20-100.git;a=commitdiff_plain;h=b5f14dad00d558caee2429d8cf03795f51167eb1 Parce que hasher à la main, c'est trop mainstream. --- diff --git a/create_password.py b/create_password.py new file mode 100755 index 0000000..237e384 --- /dev/null +++ b/create_password.py @@ -0,0 +1,20 @@ +#!/usr/bin/python +# -*- coding:utf8 -*- + +"""Récupère en parmètre un mot de passe, le sale et le hashe en sha256. + Sort un format NK2015-compliant.""" + +table="azertyuiopqsdfghjklmwxcvbn0123456789" + +import random +import hashlib +import sys + +def random_chain(size): + return "".join([random.choice(table) for i in range(size)]) + +if __name__=="__main__": + password=sys.argv[1] + sel=random_chain(8) + hashed=hashlib.sha256(sel+password).hexdigest() + print sel+"|"+hashed