What is the Python function equivalent to Crypt in PHP

0

I have a program in PHP that encrypts a password with the crypt method:

$crypt = '$1$/E0xe3/3$yPzJElk.aVSd5JoQTopDZ/';
if($crypt == crypt($_POST['key'],$crypt))

And with that I generate the following hash of this password:

*$1$Mmd/1SKE$bE44ZNJgYXDjm10rUHC5L1*

I wanted to do the same hash in Python , but I do not know how.

The command:

 *cat /etc/login.defs | grep ^ENCRYPT_METHOD*

Returns (*ENCRYPT_METHOD SHA512*)

    
asked by anonymous 07.08.2018 / 20:39

1 answer

1
import crypt

hash = '$1$/E0xe3/3$yPzJElk.aVSd5JoQTopDZ/'
crypt.crypt('marcus.mann', hash)
    
14.08.2018 / 02:28