V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
coolair
V2EX  ›  问与答

有朋友知道怎么用 Python 计算 CRC 吗?

  •  
  •   coolair · 2019-08-08 11:15:20 +08:00 · 2133 次点击
    这是一个创建于 1748 天前的主题,其中的信息可能已经有所发展或是发生改变。
    比如,这个计算,用 Python 如何实现呢?


    另外,想问下,用这个作为通讯协议,容易被破解吗?
    6 条回复    2019-08-08 11:28:32 +08:00
    mason961125
        1
    mason961125  
       2019-08-08 11:17:49 +08:00 via iPhone
    校验?通讯协议?
    tabris17
        2
    tabris17  
       2019-08-08 11:20:51 +08:00
    binascii.crc32
    itskingname
        3
    itskingname  
       2019-08-08 11:24:54 +08:00
    import binascii

    i = 123
    user_hash = binascii.crc32(str(i).encode())
    user_hash_hex = hex(user_hash)[2:]
    coolair
        4
    coolair  
    OP
       2019-08-08 11:25:15 +08:00
    @tabris17 #2 binascii.crc32 可以计算 CRC-16 吗?
    coolair
        5
    coolair  
    OP
       2019-08-08 11:26:52 +08:00
    @itskingname #3 算不到图片上的结果啊
    tabris17
        6
    tabris17  
       2019-08-08 11:28:32 +08:00
    @coolair binascii.crc_hqx
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1461 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:54 · PVG 07:54 · LAX 16:54 · JFK 19:54
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.