def test_hmac_shorten_key(self): self.assertEqual(b'short', hmac_shorten_key(b'short', 'sha1')) self.assertEqual(b'x' * 64, hmac_shorten_key(b'x' * 64, 'sha1')) self.assertEqual( b'0\xec\xd3\xf4\xb5\xcej\x1a\xc6x' b'\x15\xdb\xa1\xfb\x7f\x9f\xff\x00`\x14', hmac_shorten_key(b'l' * 65, 'sha1')) self.assertEqual(b'x' * 64, hmac_shorten_key(b'x' * 64, 'sha256')) self.assertEqual( b'l\xf9\x08}"vi\xbcj\xa9\nlkQ\x81\xd9`' b'\xbb\x88\xe9L4\x0b\xbd?\x07s/K\xae\xb9L', hmac_shorten_key(b'l' * 65, 'sha256'))
def test_hmac_shorten_key(self): self.assertEqual(b"short", hmac_shorten_key(b"short", "sha1")) self.assertEqual(b"x" * 64, hmac_shorten_key(b"x" * 64, "sha1")) self.assertEqual( b"0\xec\xd3\xf4\xb5\xcej\x1a\xc6x" b"\x15\xdb\xa1\xfb\x7f\x9f\xff\x00`\x14", hmac_shorten_key(b"l" * 65, "sha1"), ) self.assertEqual(b"x" * 64, hmac_shorten_key(b"x" * 64, "sha256")) self.assertEqual( b'l\xf9\x08}"vi\xbcj\xa9\nlkQ\x81\xd9`' b"\xbb\x88\xe9L4\x0b\xbd?\x07s/K\xae\xb9L", hmac_shorten_key(b"l" * 65, "sha256"), )