Hash: added doctests + little fixes
[python-cryptoplus.git] / src / CryptoPlus / Hash / python_RadioGatun.py
blobe823598d54155c7fbfae1cba9f10f70835dcc2ef
1 from pyradiogatun import RadioGatunType
3 __all__ = ['new']
5 def new(wl=64,data=None):
6 """Create a new pure python RadioGatun hash object
8 wl = wordlength (in bits) of the RadioGatun hash method
9 between 1 and 64 (default = 64)
10 data = if present, the method call update(arg) is made
12 EXAMPLES: (testvectors from: http://radiogatun.noekeon.org/)
13 ==========
14 >>> import python_RadioGatun
16 radiogatun[64]
17 ---------------
18 >>> hasher = python_RadioGatun.new()
19 >>> hasher.update('1234567890123456')
20 >>> hasher.hexdigest()
21 'caaec14b5b4a7960d6854709770e3071d635d60224f58aa385867e549ef4cc42'
23 >>> hasher = python_RadioGatun.new()
24 >>> hasher.update('Santa Barbara, California')
25 >>> hasher.hexdigest()
26 '0d08daf2354fa95aaa5b6a50f514384ecdd35940252e0631002e600e13cd285f'
28 radiogatun[32]
29 ---------------
30 >>> hasher = python_RadioGatun.new(32)
31 >>> hasher.update('1234567890123456')
32 >>> hasher.hexdigest()
33 '59612324f3f42d3096e69125d2733b86143ae668ae9ed561ad785e0eac8dba25'
35 >>> hasher = python_RadioGatun.new(32)
36 >>> hasher.update('Santa Barbara, California')
37 >>> hasher.hexdigest()
38 '041666388ef9655d48996a66dada1193d6646012a7b25a24fb10e6075cf0fc54'
39 """
41 crypto = RadioGatunType(wl)
42 if data:
43 crypto.update(data)
45 return crypto
47 def _test():
48 import doctest
49 doctest.testmod()
51 if __name__ == "__main__":
52 print "DOCTEST running... no messages = all good"
53 _test()