Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21464
| From | Cosmia Luna <cosmius@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | How to re-implement the crypt.crypt function? |
| Date | 2012-03-10 11:33 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <28304124.1374.1331408016748.JavaMail.geo-discussion-forums@yncd8> (permalink) |
I'm not searching for a full solution and only want to know how to use hashlib to create a equivalent string like
crypt.crypt('123456', '$6$ds41p/9VMA.BHH0U') returns the string below.
'$6$ds41p/9VMA.BHH0U$yv25s7jLxTRKLDNjIvT0Qc2jbcqdFRi5.PftO3cveTvjK49JhwCarIowOfrrNPD/PpYT3n6oNDIbjAONh8RXt1'
I tried:
from hashlib import sha512
from base64 import b64encode, b64decode
salt='ds41p/9VMA.BHH0U'
pwd='123456'
b64encode( sha512(pwd+salt).digest(), altchars='./' )
b64encode( sha512(salt+pwd).digest(), altchars='./' )
b64encode( sha512( pwd + b64decode(salt, altchars='./') ).digest(), altchars='./')
b64encode( sha512( b64decode(salt, altchars='./') + pwd ).digest(), altchars='./')
of course none of the four returns the value I want, 'yv25s7jLxTRKLDNjIvT0Qc2jbcqdFRi5.PftO3cveTvjK49JhwCarIowOfrrNPD/PpYT3n6oNDIbjAONh8RXt1', how can I get the value? I can't use crypt.crypt because of the consideration of cross-platform.
Thanks,
Cosmia
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
How to re-implement the crypt.crypt function? Cosmia Luna <cosmius@gmail.com> - 2012-03-10 11:33 -0800
Re: How to re-implement the crypt.crypt function? Roy Smith <roy@panix.com> - 2012-03-10 15:15 -0500
Re: How to re-implement the crypt.crypt function? Christian Heimes <lists@cheimes.de> - 2012-03-10 21:36 +0100
Re: How to re-implement the crypt.crypt function? Roy Smith <roy@panix.com> - 2012-03-10 15:41 -0500
Re: How to re-implement the crypt.crypt function? Christian Heimes <lists@cheimes.de> - 2012-03-10 22:07 +0100
Re: How to re-implement the crypt.crypt function? Christian Heimes <lists@cheimes.de> - 2012-03-10 21:16 +0100
Re: How to re-implement the crypt.crypt function? Cosmia Luna <cosmius@gmail.com> - 2012-03-11 03:10 -0700
Re: How to re-implement the crypt.crypt function? Cosmia Luna <cosmius@gmail.com> - 2012-03-11 03:10 -0700
csiph-web