예제 #1
0
파일: core.py 프로젝트: drostie/adso
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()
예제 #2
0
 def test(self):
     self.assertEqual(type(skein.__version__), str)
     self.assert_(
         type(skein.skein256()) is type(skein.skein512()) is type(
             skein.skein1024()))
예제 #3
0
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))
예제 #4
0
파일: TestPureSkein.py 프로젝트: blanu/Dust
def chash(data, pers=None):
  if pers:
    return skein512(data, pers=pers).digest()
  else:
    return skein512(data).digest()
예제 #5
0
def chash(data, pers=None):
    if pers:
        return skein512(data, pers=pers).digest()
    else:
        return skein512(data).digest()
예제 #6
0
파일: ciphers.py 프로젝트: drostie/adso
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()
예제 #7
0
파일: ciphers.py 프로젝트: drostie/adso
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()