Near Final PEP 247 - API for Cryptographic Hash Functions
Tim Peters
tim.one at home.com
Fri Sep 21 16:00:09 EDT 2001
[Andrew Kuchling, on
http://python.sourceforge.net/peps/pep-0247.html
]
Hash function modules define one function:
new([string])
new([key] , [string])
Create a new hashing object and return it. You can now feed
arbitrary strings into the object using its update() method,
and can ask for the hash value at any time by calling its
digest() method.
It's unclear whether all modules conforming to this spec must support both
flavors of "new". The syntax of the second flavor of new() is also unclear;
perhaps
new(key[, string])
was intended? I expect I'd like it better if the string argument always
came first, and that hash methods requiring a key require a keyword "key="
argument.
The 'string' parameter, if supplied, will be immediately
hashed into the object's starting state; an empty string or
None.
What about "an empty string or None"? That clause is dangling there without
apparent purpose.
It would be good to make explicit that
hasher = module.new(string)
is equivalent to
hasher = module.new()
hasher.update(string)
When you flesh out the "an empty string or None" clause, it would also be
good to make explicit that
hasher = module.new()
is equivalent to
hasher = module.new("")
and to
hasher = module.new(None)
Other than that stuff at the start, looks peachy!
hope-it's-ok-to-export-crytographic-pep-discussions-ly y'rs - tim
More information about the Python-list
mailing list