diff options
author | Brian Turek <brian.turek@gmail.com> | 2016-07-10 13:14:57 -0400 |
---|---|---|
committer | Brian Turek <brian.turek@gmail.com> | 2016-07-10 13:14:57 -0400 |
commit | e191a57bf7e1f8cc2ed38ac84b25ed4727ec92d5 (patch) | |
tree | 0731839e9de44da283b1fe24b70eada93efc19cc /test/genShake.py | |
parent | bc0247bcf2d60bc30720b7bb01af32d67a070c71 (diff) | |
download | jsSHA-e191a57bf7e1f8cc2ed38ac84b25ed4727ec92d5.zip jsSHA-e191a57bf7e1f8cc2ed38ac84b25ed4727ec92d5.tar.gz jsSHA-e191a57bf7e1f8cc2ed38ac84b25ed4727ec92d5.tar.bz2 |
Add support SHA3
Diffstat (limited to 'test/genShake.py')
-rw-r--r-- | test/genShake.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/genShake.py b/test/genShake.py new file mode 100644 index 0000000..ba08981 --- /dev/null +++ b/test/genShake.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python2 +import binascii + +import sha3 + +def main(): + test_vectors = { + 'Short': 'abc', + 'Medium': 'abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu', + 'Long': 'a' * 1000000 + } + + hash_funcs = {'SHAKE128': sha3.SHAKE128, 'SHAKE256': sha3.SHAKE256} + output_lens = [31, 63] + + for hash_name, hash_func in hash_funcs.items(): + for vector_name, vector_value in test_vectors.items(): + for output_len in output_lens: + print('%s with %s Input and %d bit Output: %s' % ( + hash_name, + vector_name, + output_len * 8, + binascii.hexlify(hash_func([ord(c) for c in vector_value], output_len)) + ) + ) + +if ('__main__' == __name__): + main() |