Imported Upstream version 3.2.2
[debian/gnuradio] / gnuradio-core / src / python / gnuradio / gruimpl / crc.py
index 956e3f7bbb5b925d449652bb6fb275492809622e..d31aca0ea7c26ec6327379633872da7ac34d301c 100644 (file)
@@ -1,5 +1,5 @@
 #
-# Copyright 2005 Free Software Foundation, Inc.
+# Copyright 2005,2007 Free Software Foundation, Inc.
 # 
 # This file is part of GNU Radio
 # 
@@ -25,9 +25,11 @@ import struct
 
 def gen_and_append_crc32(s):
     crc = gr.crc32(s)
-    return s + struct.pack(">I", hexint(crc))
+    return s + struct.pack(">I", hexint(crc) & 0xFFFFFFFF)
 
 def check_crc32(s):
+    if len(s) < 4:
+        return (False, '')
     msg = s[:-4]
     #print "msg = '%s'" % (msg,)
     actual = gr.crc32(msg)