crc16
介绍
查表法实现crc16算法.参数模型是CRC-16/MODBUS 多项式是8005。
API
"""
计算校验和.参数模型是CRC-16/MODBUS 多项式是8005,返回值是高字节在前的16位校验值
"""
def checksum(data: bytearray) -> int
示例
class _UnitTest(unittest.TestCase):
def test_case1(self):
data = bytearray([1, 2, 3, 4, 5, 6, 7, 8, 9])
self.assertEqual(crcmodbus.checksum(data), 0x0eb2)
def test_case2(self):
data = bytearray([3, 1, 4])
self.assertEqual(crcmodbus.checksum(data), 0x8193)
def test_case3(self):
data = bytearray([0x19, 0x89, 0x56])
self.assertEqual(crcmodbus.checksum(data), 0x47a9)
if __name__ == '__main__':
suite = unittest.TestSuite()
suite.addTest(_UnitTest('test_case1'))
suite.addTest(_UnitTest('test_case2'))
suite.addTest(_UnitTest('test_case3'))
runner = unittest.TextTestRunner()
runner.run(suite)
Metadata
Release files for crcmodbus 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| crcmodbus-1.3.tar.gz | 2.6 kB | Without provenance | Details |
Release files / crcmodbus-1.3.tar.gz
| Download URL | crcmodbus-1.3.tar.gz |
|---|---|
| Size | 2.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d96b8e7304c1eecf8f2d918c9f918ca6c1de5eaa32f9afb65baa390fd478f4d
|
|
BLAKE2b-256 checksum How to use checksums |
69d002851471a63f7e84195e73390e7dfd5a69bb7b865569e88e82fc79ee1f87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.8.7
|
Security for crcmodbus 1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.