From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from blyat.fensystems.co.uk (blyat.fensystems.co.uk [54.246.183.96]) by mx.groups.io with SMTP id smtpd.web10.10576.1662029676895438226 for ; Thu, 01 Sep 2022 03:54:37 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: ipxe.org, ip: 54.246.183.96, mailfrom: mcb30@ipxe.org) Received: from [IPV6:2a00:23c6:5486:8700:eaa7:4ea6:88e4:6f0e] (unknown [IPv6:2a00:23c6:5486:8700:eaa7:4ea6:88e4:6f0e]) by blyat.fensystems.co.uk (Postfix) with ESMTPSA id 3C894443BC; Thu, 1 Sep 2022 10:54:33 +0000 (UTC) Message-ID: <815399fe-36e9-2365-470c-d25b60a08494@ipxe.org> Date: Thu, 1 Sep 2022 11:54:30 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Subject: Re: [edk2-devel] [PATCH] [edk2-basetools]GenCrc32:Convert the C tool of calculating the crc32 into a python tool To: devel@edk2.groups.io, wenzhao1.li@intel.com Cc: Bob Feng , Liming Gao , Yuwei Chen References: <20220901065702.2412-1-wenzhao1.li@intel.com> From: "Michael Brown" In-Reply-To: <20220901065702.2412-1-wenzhao1.li@intel.com> X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on blyat.fensystems.co.uk Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 01/09/2022 07:57, liwenzha wrote: > This patch converts the C tool of calculating the crc32 value of file into > a python file. To realize this,after reading the data into the file in > binary form from an original file,a lookup table is listed to do XOR and > shifting calculation for each bit in the file. Python has binascii.crc32 as part of the standard library. You can throw away the mCrcTable and all of the open-coded CRC32 calculation logic, and just do: from binascii import crc32 CrcOut = crc32(filebytes) HTH, Michael