A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2004-June/045743.html below:

[Python-Dev] SHA-256 module

[Python-Dev] SHA-256 moduleGregory P. Smith greg at electricrain.com
Tue Jun 29 15:04:21 EDT 2004
On Tue, Jun 29, 2004 at 02:40:21PM -0400, Barry Warsaw wrote:
> On Tue, 2004-06-29 at 02:25, Raymond Hettinger wrote:
> > > > On Tue, Jun 29, 2004 at 04:10:22PM +0100, Armin Rigo wrote:
> > > > > We may consider whether adding, over time, a bunch of modules
> > named
> > > shaXXX
> > > > > doesn't mean we should start thinking about a way to group all
> > these
> > > > > algorithms into a single module.
> > > >
> > > > It would be possible to change the signature of sha.new() to
> > > > sha.new('string', bits=256) and have all the variants in one module,
> > > > if we want SHA-256 but not a separate module.
> > > 
> > > That seems like a very nice solution to me.
> > 
> > +1
> 
> BTW, would it raise an exception (ValueError?) for bit sizes it doesn't
> know about?

I'd sure hope so.  Personally i prefer to not use a bits argument as
it passing a function reference to a hash algorithm needlessly require
a lambda.  Instead do as someone else suggested and make a sha.sha256()
function:

do_thing_and_hash(things=thingList, hashmaker=lambda x: sha.new(x, bits=256))
vs
do_thing_and_hash(things=thingList, hashmaker=sha.sha256)

The only official SHAs defined are sha1, sha256, sha384 and sha512 and
are typically referred to as a single unit name of "sha1" or "sha512"
not "the SHA which is 512 bits."  using a simple function name that is
the common spoken name is nicer.

Perl uses a top level module to contain all its hash functions
(Digest::MD5, Digest::SHA1, etc).  I agree that we should do that same
(as someone else already suggested).

Realistically, lets not reinvent the wheel.  See the pycrypto module:

 http://www.amk.ca/python/code/crypto.html

MD5 and SHA1 are the most common types of hashes in use today; those
make sense to have in the base python distro.  Does sha256 or greater?

If someone needs something better than sha1 there is a good chance
that they are also dealing with symmetric encryption or public key
authentication and would need a module like pycrypto anyways.

-g


More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4