def _hash(message, length, pers, **kwargs): for key in kwargs: kwargs[key] = _bytes(kwargs[key]) pers = b'20100914 [email protected] adso/' + pers.encode('utf-8') s = skein.skein512(digest_bits=length, pers=pers, **kwargs) s.update(_bytes(message)) return s.digest()
def test(self): self.assertEqual(type(skein.__version__), str) self.assert_( type(skein.skein256()) is type(skein.skein512()) is type( skein.skein1024()))
import sys from skein import skein512 from dust.core.util import encode v3=(sys.version[0]=='3') ### Print hash of MSG if called directly ### if __name__ == "__main__": if v3: MSG = bytes("Nobody inspects the spammish repetition", 'ascii') else: MSG = "Nobody inspects the spammish repetition" hash = skein512(MSG, digest_bits=256).digest() print(encode(hash)) hash = skein512(MSG, digest_bits=512).digest() print(encode(hash))
def chash(data, pers=None): if pers: return skein512(data, pers=pers).digest() else: return skein512(data).digest()
def _skein512stream(key, iv, data): stream = array('B', skein.skein512(digest_bits=8 * len(data), mac=key, nonce=iv).digest()) for i in range(0, len(data)): stream[i] ^= data[i] return stream.tostring()
def derive_key(key, message, length): "Hashes a message with a key to produce a <length>-bit derived key. This function is adso-specific." s = skein.skein512(digest_bits=length, mac=key, pers=b'20100914 [email protected] adso/key_derivation') s.update(message); return s.digest()