Python SHA512encryption with PHP
Question: This is the first time I am trying to deal with a python code. My client has
recently gave me a python code:

    
    
    python -c 'import crypt; print crypt.crypt("Pa55w0rd!", "$6$x88yEvVg")'
    

Which is used to encrypt the password, in the above code.

The password is **Pa55w0rd!** and the salt value is **x88yEvVg** . Can I
execute the above code in PHP? I have tried doing this:

    
    
    echo exec(`python -c "import crypt;print crypt.crypt('Pa55w0rd!', '\$6\$x88yEvVg\')"`);
    

Thanks.


Answer: Do you absolutely need to encrypt using python? Depending on your PHP version
you could do this for PHP >= 5.3:

    
    
    openssl_digest("Pa55w0rd!"."$6$x88yEvVg", "sha512");
    

and this for PHP 5.2 or 5.1

    
    
    hash("sha512", "Pa55w0rd!"."$6$x88yEvVg");
    

This assumes that your salt value is just being concatenated with your
password value.

