def test_sha256d_truncated(self): h1 = hashutil.tagged_hash(b"tag1", b"value", 16) h2 = hashutil.tagged_hasher(b"tag1", 16) h2.update(b"value") h2 = h2.digest() self.failUnlessEqual(len(h1), 16) self.failUnlessEqual(len(h2), 16) self.failUnlessEqual(h1, h2)
def test_sha256d(self): h1 = hashutil.tagged_hash(b"tag1", b"value") self.assertIsInstance(h1, bytes) h2 = hashutil.tagged_hasher(b"tag1") h2.update(b"value") h2a = h2.digest() h2b = h2.digest() self.assertIsInstance(h2a, bytes) self.failUnlessEqual(h1, h2a) self.failUnlessEqual(h2a, h2b)