Generating md5 encrypted password for chpasswd

If you want to generate properly encrypted password to feed to chpasswd, the most easier and proper way is to do that from command line :

echo "encryptedpassword"|openssl passwd -1 -stdin

If you want to generate in pure python you can do it like that :

def md5crypt(password, salt, magic='$1$'):
[...]