From 12b49d5369063610f3379d98ecccd0733aed0cfb Mon Sep 17 00:00:00 2001 From: Christophe Oosterlynck Date: Wed, 12 Nov 2008 17:53:42 +0100 Subject: [PATCH] Hash API: unified -> default value for data in new() is None instead of "" --- src/CryptoPlus/Hash/RIPEMD.py | 2 +- src/CryptoPlus/Hash/python_MD5.py | 2 +- src/CryptoPlus/Hash/python_RadioGatun.py | 6 +++--- src/CryptoPlus/Hash/python_SHA.py | 2 +- src/CryptoPlus/Hash/python_SHA224.py | 2 +- src/CryptoPlus/Hash/python_SHA256.py | 2 +- src/CryptoPlus/Hash/python_SHA384.py | 2 +- src/CryptoPlus/Hash/python_SHA512.py | 2 +- src/CryptoPlus/Hash/python_whirlpool.py | 2 +- test/test.py | 4 ++-- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/CryptoPlus/Hash/RIPEMD.py b/src/CryptoPlus/Hash/RIPEMD.py index e4f889e..b0e4819 100644 --- a/src/CryptoPlus/Hash/RIPEMD.py +++ b/src/CryptoPlus/Hash/RIPEMD.py @@ -1,6 +1,6 @@ from Crypto.Hash import RIPEMD -def new(data=""): +def new(data=None): """Create a new RIPEMD-160 hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_MD5.py b/src/CryptoPlus/Hash/python_MD5.py index ed26b93..6dc5522 100644 --- a/src/CryptoPlus/Hash/python_MD5.py +++ b/src/CryptoPlus/Hash/python_MD5.py @@ -2,7 +2,7 @@ import pymd5 __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python MD5 hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_RadioGatun.py b/src/CryptoPlus/Hash/python_RadioGatun.py index e823598..dd90ec2 100644 --- a/src/CryptoPlus/Hash/python_RadioGatun.py +++ b/src/CryptoPlus/Hash/python_RadioGatun.py @@ -2,7 +2,7 @@ from pyradiogatun import RadioGatunType __all__ = ['new'] -def new(wl=64,data=None): +def new(data=None,wl=64): """Create a new pure python RadioGatun hash object wl = wordlength (in bits) of the RadioGatun hash method @@ -27,12 +27,12 @@ def new(wl=64,data=None): radiogatun[32] --------------- - >>> hasher = python_RadioGatun.new(32) + >>> hasher = python_RadioGatun.new(wl=32) >>> hasher.update('1234567890123456') >>> hasher.hexdigest() '59612324f3f42d3096e69125d2733b86143ae668ae9ed561ad785e0eac8dba25' - >>> hasher = python_RadioGatun.new(32) + >>> hasher = python_RadioGatun.new(wl=32) >>> hasher.update('Santa Barbara, California') >>> hasher.hexdigest() '041666388ef9655d48996a66dada1193d6646012a7b25a24fb10e6075cf0fc54' diff --git a/src/CryptoPlus/Hash/python_SHA.py b/src/CryptoPlus/Hash/python_SHA.py index e173e05..c9043f1 100644 --- a/src/CryptoPlus/Hash/python_SHA.py +++ b/src/CryptoPlus/Hash/python_SHA.py @@ -2,7 +2,7 @@ import pysha __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python SHA hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_SHA224.py b/src/CryptoPlus/Hash/python_SHA224.py index c69a56f..5c20786 100644 --- a/src/CryptoPlus/Hash/python_SHA224.py +++ b/src/CryptoPlus/Hash/python_SHA224.py @@ -2,7 +2,7 @@ from pysha224 import sha224 __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python SHA-224 hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_SHA256.py b/src/CryptoPlus/Hash/python_SHA256.py index 2c771fb..da69327 100644 --- a/src/CryptoPlus/Hash/python_SHA256.py +++ b/src/CryptoPlus/Hash/python_SHA256.py @@ -2,7 +2,7 @@ from pysha256 import sha256 __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python SHA-256 hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_SHA384.py b/src/CryptoPlus/Hash/python_SHA384.py index 8478296..9767a37 100644 --- a/src/CryptoPlus/Hash/python_SHA384.py +++ b/src/CryptoPlus/Hash/python_SHA384.py @@ -2,7 +2,7 @@ from pysha384 import sha384 __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python SHA-384 hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_SHA512.py b/src/CryptoPlus/Hash/python_SHA512.py index a869803..ae0daf8 100644 --- a/src/CryptoPlus/Hash/python_SHA512.py +++ b/src/CryptoPlus/Hash/python_SHA512.py @@ -2,7 +2,7 @@ from pysha512 import sha512 __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python SHA-512 hash object data = initial input (raw string) to the hashing object diff --git a/src/CryptoPlus/Hash/python_whirlpool.py b/src/CryptoPlus/Hash/python_whirlpool.py index b8f223b..1a71005 100644 --- a/src/CryptoPlus/Hash/python_whirlpool.py +++ b/src/CryptoPlus/Hash/python_whirlpool.py @@ -2,7 +2,7 @@ import pywhirlpool __all__ = ['new','digest_size'] -def new(data=""): +def new(data=None): """Create a new pure python Whirlpool hash object data = initial input (raw string) to the hashing object diff --git a/test/test.py b/test/test.py index 40397c1..e7a8f4a 100644 --- a/test/test.py +++ b/test/test.py @@ -30,14 +30,14 @@ from CryptoPlus.Hash import python_RadioGatun for i in range(0,len(radiogatun32)/2): msg = radiogatun32["msg%i"%i] hash = radiogatun32["hash%i"%i] - hasher = python_RadioGatun.new(32,msg) + hasher = python_RadioGatun.new(msg,wl=32) if hash <> hasher.hexdigest().upper(): print 'ERROR! RadioGatun[32] in %i'%i for i in range(0,len(radiogatun64)/2): msg = radiogatun64["msg%i"%i] hash = radiogatun64["hash%i"%i] - hasher = python_RadioGatun.new(64,msg) + hasher = python_RadioGatun.new(msg,wl=64) if hash <> hasher.hexdigest().upper(): print 'ERROR! RadioGatun[64] in %i'%i -- 2.11.4.GIT