added encode and decode methods for crc