Beispiel #1
0
 def test02(self):
     data = 100*"1"
     expected_result = 2326594156
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
Beispiel #2
0
    def test03(self):
        data = 10*"0123456789"
        expected_result = 3774345973
        result = digital.crc32(data)
        #print hex(result)

        self.assertEqual(expected_result, result)
Beispiel #3
0
 def test01(self):
     data = 100*"0"
     expected_result = 2943744955
     result = digital.crc32(data)
     #print hex(result)
     
     self.assertEqual(expected_result, result)
Beispiel #4
0
def check_crc32(s):
    if len(s) < 4:
        return (False, '')
    msg = s[:-4]
    #print "msg = '%s'" % (msg,)
    actual = digital_swig.crc32(msg)
    (expected,) = struct.unpack(">I", s[-4:])
    # print "actual =", hex(actual), "expected =", hex(expected)
    return (actual == expected, msg)
Beispiel #5
0
def gen_and_append_crc32(s):
    crc = digital_swig.crc32(s)
    return s + struct.pack(">I", gru.hexint(crc) & 0xFFFFFFFF)