1

Using an answer from a serverfault submission I generated password hashes for /etc/shadow, however the result on Windows (Cygwin) or Mac:

mistral.local:~(16)+>- python -c 'import crypt; print crypt.crypt("test","$6$randomsalt")'
$6asQOJRqB1i2
mistral.local:~(17)+>-

is very different to that on Solaris 10 & 11:

pkearns@solaris11:~/tmp$ python -c 'import crypt; print crypt.crypt("test","$6$randomsalt")'
$6$randomsalt$gZCCiaoqM7ivJDVPx3T4hr23J7WDQjneAucycYvJeMoBZHAx9bx8y2pUL.hE2MhbSRcgTjEE9klIhBq1WF8Pa1
pkearns@solaris11:~/tmp$

Can anyone explain that?

Community
  • 1
  • 1
Philip Kearns
  • 377
  • 4
  • 14

2 Answers2

1

Crypt is a function to make hash consistent with system.

I'm not sure about Mac and Windows, but on a linux system it's a modified DES, for Solaris it's plugable algorithms, with SHA-256 or SHA-512 recommended to use.

If you need to make a password hash for you software - you'd better use hashlib.

DukeLion
  • 356
  • 3
  • 4
  • You mean like this (to borrow from another submission): `python -c "import hashlib; m = hashlib.sha512(); m.update('Ii4CGbr7'+'usrpw123'); print m.hexdigest()"` – Philip Kearns Aug 16 '13 at 10:31
0

crypt module is only available in Unix.

Maybe you're using your own version of crypt in your system.

Try following command to tell where the crypt module come from:

python -c 'import crypt; print crypt.__file__'
falsetru
  • 357,413
  • 63
  • 732
  • 636
  • I should have said the Windows one was Cygwin (/usr/lib/python2.7/lib-dynload/crypt.dll); I have amended my submission accordingly. That `__file__` is handy though. – Philip Kearns Aug 16 '13 at 10:15