[PYTHON-CRYPTO] Comments on PEP 247 (Hashing)
Rich Salz
rsalz at ZOLERA.COM
Tue Sep 25 16:48:43 CEST 2001
> > 1. Why is there a new method; why isn't the classic
> > constructor good enough? The PEP needs to justify this.
>
> That way you don't have to worry about what the
> constructor is called.
This seems a weak argument. My code already has to know what module to
import:
from hash import SHA1
s = SHA1.SHA1()
as opposed to
from hash import SHA1
s = SHA1.new()
or
from hash import SHA1 as HASH
s = HASH.new()
The first is the standard pythnon way to do things, the second shows no
gain for being non-standard, and the third seems like risky code. Am I
missing something?
I think the PEP should (a) justify why new() is defined; and (b) define
standard Python constructor use.
> Maybe instead:
> new(str="")
> new(key, str="")
>
> Having the initial string is useful:
> digest = sha.new(str).digest()
If update() (or write() :) returned self, you could do
digest = sha1.sha1().update(str).digest()
I don't care, as long as the initial text is an explicit keyword. :
/r$
--
Zolera Systems, Your Key to Online Integrity
Securing Web services: XML, SOAP, Dig-sig, Encryption
http://www.zolera.com
More information about the python-crypto
mailing list