]> gitweb.pimeys.fr Git - scripts-20-100.git/blobdiff - create_password.py
Parce que hasher à la main, c'est trop mainstream.
[scripts-20-100.git] / create_password.py
diff --git a/create_password.py b/create_password.py
new file mode 100755 (executable)
index 0000000..237e384
--- /dev/null
@@ -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