addsub.cpp

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

CPP
45
字号
// Created:12-14-98
// By Jeff Connelly

// ADD/SUB encryption

// Adds or subtracts the password with the data, developed by me

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

// Encrypt using ADD/SUB
void EXPORT addsub_encode(char* pw)
{
    register char c;
    register int i = 0;
    register int pwlen = strlen(pw);

    while (!end_of_data())
    {
        c = read_byte();
        // Note: 'c' might wrap around, this is not a bug
        write_byte(c + pw[i % pwlen]);
        ++i;
    }
}

// Decode using ADD/SUB
void EXPORT addsub_decode(char* pw)
{
    register char c;
    register int i = 0;
    register int pwlen = strlen(pw);

    while (!end_of_data())
    {
        c = read_byte();
        write_byte(c - pw[i % pwlen]);
        ++i;
    }
}

    

⌨️ 快捷键说明

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