BCC(Block Check Character),俗称异或校验。BCC的实现方法:将所有数据都和一个指定的初始值(通常是0)异或一次,所得结果为校验值。BCC一般只是用来排错的,并不是加密算法。
#include <iostream>
#include <string>
unsigned char CalcBCC(const std::string &str)
{
unsigned char bcc = 0;
for (int i = 0; i < str.length(); i++)
{
bcc ^= str[i];
}
return bcc;
}
int main()
{
std::string content = "@hellokandy123";
unsigned char buff = CalcBCC(content);
std::cout << "buff=" << buff;
return 0;
}