关于mysql crc32和python crc32

binascii. crc32 ( data [ , crc ] )

Compute CRC-32, the 32-bit checksum of data, starting with an initial crc. This is consistent with the ZIP file checksum. Since the algorithm is designed for use as a checksum algorithm, it is not suitable for use as a general hash algorithm. Use as follows:

print
 binascii
.
crc32
(
"hello world"
)

# Or, in two pieces:
crc = binascii . crc32 ( "hello" )
crc = binascii . crc32 ( " world" , crc ) & 0xffffffff
print 'crc32 = 0x %08x ' % crc

Note

To generate the same numeric value across all Python versions and platforms use crc32(data) & 0xffffffff. If you are only using the checksum in packed binary format this is not necessary as the return value is the correct 32bit binary representation regardless of sign.

Changed in version 2.6: The return value is in the range [-2**31, 2**31-1] regardless of platform. In the past the value would be signed on some platforms and unsigned on others. Use & 0xffffffff on the value if you want it to match 3.0 behavior.

Changed in version 3.0: The return value is unsigned and in the range [0, 2**32-1] regardless of platform.

 

CRC32(expr )

Computes a cyclic redundancy check value and returns a 32-bit unsigned value. The result is NULL if the argument is NULL . The argument is expected to be a string and (if possible) is treated as one if it is not.

mysql> SELECT CRC32('MySQL');


-> 3259397556
mysql> SELECT CRC32('mysql');
-> 2501908538
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值