Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python 3.3 can't import Crypt

When I type in import Crypt on the command line it says:

>>>import crypt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python33\lib\crypt.py", line 3, in <module>
    import _crypt
ImportError: No module named '_crypt'
like image 813
TrevorPeyton Avatar asked Dec 11 '22 17:12

TrevorPeyton


2 Answers

The crypt module is an interface to the Unix crypt library which is used for encrypting Unix passwords. It is documented as not being available on Windows. It is not a general purpose cryptography library.

like image 194
casevh Avatar answered Dec 26 '22 23:12

casevh


If all you're looking for is an implementation of crypt(3), I've knocked up a pure-Python implementation here, ported from this public domain C implementation. It's pretty damn slow (about 2800 times slower than Python's built-in crypt on my machine, which is already about half the speed of OpenSSL's DES_crypt), but if you're just calculating the occasional hash, that shouldn't really be a problem.

Are you writing an imageboard, by any chance?

like image 27
Cairnarvon Avatar answered Dec 26 '22 23:12

Cairnarvon