Search code examples
pythonmacoshashshacrypt

crypt does not work in osx, returns wrong value


I'm using an OSX 10.9 (last version) with the last Xcode. When I execute the following command:

python -c 'import crypt; print crypt.crypt("test", "$6$random_salt")'

I get this as an answer:

$6asQOJRqB1i2

but if I execute the same in a debian machine (same version of python) I get the following:

$6$random_salt$sJ0ZOQCUESBs9rYCOLCqGV93zg1cSDgZV/FF6ZBzpnvNUVODwaaVoPV2SiL0ur7Sexh02hMmXdSBOa216GWoh.

What is wrong with my machine?


Solution

  • The problem seems to be in the crypt implementation as @dukswuff comments. If anyone ends up in the same problem, there is a python alternative solution you can read here: https://stackoverflow.com/a/17992126/2208811