Well, today I was checking the hashlib module in python, but then I found something that I still can't figure out.
Inside this python module, there is an import that I can't follow. I goes like this:
def __get_builtin_constructor(name):
if name in ('SHA1', 'sha1'):
import _sha
return _sha.new
I tried to import the _sha module from a python shell, but is seems that it cannot be reached that way.My first guess is that it's a C module, but I'm not sure.
So tell me guys, do you know where is that module? How do they import it?
Seems that you're python installation has sha compiled inside _haslib instead of _sha (both C modules). From hashlib.py in python 2.6:
Actually, the _sha module is provided by shamodule.c and _md5 is provided by md5module.c and md5.c and both will be built only when your Python is not compiled with OpenSSL by default.
You can find the details in
setup.py
in your Python Source tarball.Most often, your Python is built with Openssl library and in that case, those functions are provided by the OpenSSL libraries itself.
Now, if you want them separately, then you can build your Python without OpenSSL or better yet, you can build with pydebug option and have them.
From your Python Source tarball:
And there you go: