Skip to content

Commit 12b49d5

Browse files
author
Christophe Oosterlynck
committed
Hash API: unified -> default value for data in new() is None instead of ""
1 parent 7b516f8 commit 12b49d5

File tree

10 files changed

+13
-13
lines changed

10 files changed

+13
-13
lines changed

src/CryptoPlus/Hash/RIPEMD.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from Crypto.Hash import RIPEMD
22

3-
def new(data=""):
3+
def new(data=None):
44
"""Create a new RIPEMD-160 hash object
55
66
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_MD5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python MD5 hash object
77
88
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_RadioGatun.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new']
44

5-
def new(wl=64,data=None):
5+
def new(data=None,wl=64):
66
"""Create a new pure python RadioGatun hash object
77
88
wl = wordlength (in bits) of the RadioGatun hash method
@@ -27,12 +27,12 @@ def new(wl=64,data=None):
2727
2828
radiogatun[32]
2929
---------------
30-
>>> hasher = python_RadioGatun.new(32)
30+
>>> hasher = python_RadioGatun.new(wl=32)
3131
>>> hasher.update('1234567890123456')
3232
>>> hasher.hexdigest()
3333
'59612324f3f42d3096e69125d2733b86143ae668ae9ed561ad785e0eac8dba25'
3434
35-
>>> hasher = python_RadioGatun.new(32)
35+
>>> hasher = python_RadioGatun.new(wl=32)
3636
>>> hasher.update('Santa Barbara, California')
3737
>>> hasher.hexdigest()
3838
'041666388ef9655d48996a66dada1193d6646012a7b25a24fb10e6075cf0fc54'

src/CryptoPlus/Hash/python_SHA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python SHA hash object
77
88
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_SHA224.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python SHA-224 hash object
77
88
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_SHA256.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python SHA-256 hash object
77
88
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_SHA384.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python SHA-384 hash object
77
88
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_SHA512.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python SHA-512 hash object
77
88
data = initial input (raw string) to the hashing object

src/CryptoPlus/Hash/python_whirlpool.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
__all__ = ['new','digest_size']
44

5-
def new(data=""):
5+
def new(data=None):
66
"""Create a new pure python Whirlpool hash object
77
88
data = initial input (raw string) to the hashing object

test/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
for i in range(0,len(radiogatun32)/2):
3131
msg = radiogatun32["msg%i"%i]
3232
hash = radiogatun32["hash%i"%i]
33-
hasher = python_RadioGatun.new(32,msg)
33+
hasher = python_RadioGatun.new(msg,wl=32)
3434
if hash <> hasher.hexdigest().upper():
3535
print 'ERROR! RadioGatun[32] in %i'%i
3636

3737
for i in range(0,len(radiogatun64)/2):
3838
msg = radiogatun64["msg%i"%i]
3939
hash = radiogatun64["hash%i"%i]
40-
hasher = python_RadioGatun.new(64,msg)
40+
hasher = python_RadioGatun.new(msg,wl=64)
4141
if hash <> hasher.hexdigest().upper():
4242
print 'ERROR! RadioGatun[64] in %i'%i
4343

0 commit comments

Comments
 (0)