| 10 | class TestCryptBitcoin: |
| 11 | |
| 12 | def testSha(self, site): |
| 13 | file_path = site.storage.getPath("dbschema.json") |
| 14 | assert CryptHash.sha512sum(file_path) == sha512t_sum_hex |
| 15 | assert CryptHash.sha512sum(open(file_path, "rb")) == sha512t_sum_hex |
| 16 | assert CryptHash.sha512sum(open(file_path, "rb"), format="digest") == sha512t_sum_bin |
| 17 | |
| 18 | assert CryptHash.sha256sum(file_path) == sha256_sum_hex |
| 19 | assert CryptHash.sha256sum(open(file_path, "rb")) == sha256_sum_hex |
| 20 | |
| 21 | with open(file_path, "rb") as f: |
| 22 | hash = CryptHash.Sha512t(f.read(100)) |
| 23 | hash.hexdigest() != sha512t_sum_hex |
| 24 | hash.update(f.read(1024 * 1024)) |
| 25 | assert hash.hexdigest() == sha512t_sum_hex |
| 26 | |
| 27 | def testRandom(self): |
| 28 | assert len(CryptHash.random(64)) == 64 |