File: test_crc32.py

package info (click to toggle)
2ping 3.2.1-1%2Bdeb9u1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 368 kB
  • sloc: python: 2,537; sh: 80; makefile: 36
file content (20 lines) | stat: -rw-r--r-- 491 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env python

import unittest
from twoping import crc32
import hmac


class TestCRC32(unittest.TestCase):
    def test_crc32(self):
        c = crc32.new()
        c.update('Data to hash')
        self.assertEqual(bytearray(c.digest()), bytearray(b'\x44\x9e\x0a\x5c'))

    def test_hmac(self):
        h = hmac.new('Secret key', 'Data to hash', crc32)
        self.assertEqual(bytearray(h.digest()), bytearray(b'\x3c\xe1\xb6\xb9'))


if __name__ == '__main__':
    unittest.main()