How to re-implement the crypt.crypt function?

Cosmia Luna cosmius at gmail.com
Sun Mar 11 06:10:19 EDT 2012


On Sunday, March 11, 2012 4:16:52 AM UTC+8, Christian Heimes wrote:
> Am 10.03.2012 20:33, schrieb Cosmia Luna:
> > I'm not searching for a full solution and only want to know how to use hashlib to create a equivalent string like 
> 
> If you chance your mind and choose to use a full solution, then I highly
> recommend passlib [1]. It has an implementation of SHA-512 crypt as
> indicated by the number 6 in the header of your string.
> 
> By the way "$6$ds41p/9VMA.BHH0U" is *not* the salt. Just
> "ds41p/9VMA.BHH0U" is the salt, 6 is a hash identifier.
> 
> Christian
> 
> [1] http://packages.python.org/passlib/

PassLib works for me. What I want is passlib.context, I need it in consideration of forward compatibility.

Thanks a lot.

But I still want to know how it is implemented, I read passlib's source but I found he/she re-implemented hashlib, which I can't understand. Now I knows that the encoding is hash64 instead of base64, but I can't know that. PassLib is too difficult for me. Anyone knows the accurate process?

Cosmia



More information about the Python-list mailing list