mod256.cpp

来自「非常好用的五子棋游戏源码」· C++ 代码 · 共 30 行

CPP
30
字号
// Created:10-31-98
// By Jeff Connelly


// Modulo 256 Checksum Generation

// Based on the (example) algorithm from document
// "A Painless Guide to CRC Error Detection Algorithms"
// by Ross Williams, 1993.

// As the document above explained that this is not a very good checksum
// method.  There is a 1/256 chance that an error will not be caught!

#include "stdafx.h"
#define EXPORTING
#include "comprlib.h"

unsigned char EXPORT mod256_checksum()
{
    register char c;
    register char checksum = 0;

    while (!end_of_data())
    {
        c = read_byte();
        checksum += c % 256;
    }
	return checksum;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?