Tuesday, September 27, 2016

[yrwkbxjr] Key stretching in Python

A demonstration of how to increase the number of rounds of password hashing for generating a crypt(3)-style password hash (e.g., /etc/passwd or /etc/shadow), similar to the mkpasswd utility.

# python3

import crypt
# defaults to SHA-512
salt=crypt.mksalt()
# 10 million rounds takes 9 seconds on my computer
salt=salt[0:3] + "rounds=10000000$" + salt[3:19]
print(crypt.crypt("my_password",salt));

No comments :