SNAPKITTYWEST commited on
Commit
dde6520
·
verified ·
1 Parent(s): 1b121b8

Mirror from SNAPKITTYWEST: tests/test_sha256.py

Browse files
Files changed (1) hide show
  1. tests/test_sha256.py +19 -0
tests/test_sha256.py ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sha256.sha256_impl import sha256_hex
2
+
3
+ def test_empty():
4
+ assert sha256_hex(b'') == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
5
+
6
+ def test_abc():
7
+ assert sha256_hex(b'abc') == "ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad"
8
+
9
+ def test_long():
10
+ assert sha256_hex(b'abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq') == \
11
+ "248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1"
12
+
13
+ def test_string_input():
14
+ assert sha256_hex("abc") == sha256_hex(b'abc')
15
+
16
+ def test_vectors():
17
+ from sha256.vectors import VECTORS
18
+ for data, expected in VECTORS[:-1]: # skip 1M 'a' test for speed
19
+ assert sha256_hex(data) == expected, f"failed for {data[:20]!r}"