Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #21464
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail |
|---|---|
| From | Cosmia Luna <cosmius@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | How to re-implement the crypt.crypt function? |
| Date | Sat, 10 Mar 2012 11:33:36 -0800 (PST) |
| Organization | http://groups.google.com |
| Lines | 23 |
| Message-ID | <28304124.1374.1331408016748.JavaMail.geo-discussion-forums@yncd8> (permalink) |
| NNTP-Posting-Host | 74.207.251.187 |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1 |
| X-Trace | posting.google.com 1331408437 16208 127.0.0.1 (10 Mar 2012 19:40:37 GMT) |
| X-Complaints-To | groups-abuse@google.com |
| NNTP-Posting-Date | Sat, 10 Mar 2012 19:40:37 +0000 (UTC) |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=74.207.251.187; posting-account=oNuSIgoAAAAZId4Ea0hBMGd7JwNhEw7j |
| User-Agent | G2/1.0 |
| X-Received-Bytes | 1876 |
| Xref | csiph.com comp.lang.python:21464 |
Show key headers only | View raw
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