donljt2606 2013-06-27 16:24
浏览 53

将校验和附加到整数的函数

I have a function gen_seq that return a random generated integer of length n

e.g.

gen_seq(5); // return a randomly generated int of length n, e.g. 12345

Now, I want a simple function that in append the checksum the end of function

get_seq_with_checksum(5); // return 12345[28]
is_valid_seq(n); // check if a given string is valid according to the input function
  1. What would be a good fit algorithm pairs for function get_seq_with_checksum & is_valid_seq?
  • 写回答

1条回答 默认 最新

  • dongliao8069 2013-06-27 17:09
    关注

    A simple parity word should do pretty much what you're after – XOR each byte of the message together to create the checksum, and verify similarly.

    评论

报告相同问题?

悬赏问题

  • ¥15 keil的map文件中Image component sizes各项意思
  • ¥30 BC260Y用MQTT向阿里云发布主题消息一直错误
  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)