📄 crypt.cpp
字号:
// Crypt.cpp : Defines the entry point for the console application.
// Stone Networking's SN Crypt
#include "iostream.h"
#include "io.h"
#include <fcntl.h>
#include <process.h>
#include <stdlib.h>
char data[127]; char cypher[127]; char key[127]; int way;
__int8 matrix[7]; __int32 timesmorphed;
int MatrixMorph(void);
void __stdcall EncryptThis(char Infile[127], char Keyfile[127], char Outfile[127]);
void __stdcall DecryptThis(char Infile[127], char Keyfile[127], char Outfile[127]);
int main(int argc, char* argv[])
{
cout<<"Please enter a key file name.\n";
cin>>key;
cout<<"Please enter the in file name.\n";
cin>>data;
cout<<"Please enter the out file name.\n";
cin>>cypher;
cout<<"1 = Encrypt or 0 = Decrypt?\n";
cin>>way;
if(!((way == 1) || (way == 0)))
{
cout<<"Error in Input";
exit(2001);
};
cout<<"Please wait. Processing...\n";
if(way == 1)
{
EncryptThis(data, key, cypher);
};
if(way == 0)
{
DecryptThis(data, key, cypher);
};
cout<<"Done.\n";
return 0;
}
void __stdcall EncryptThis(char Infile[127], char Keyfile[127], char Outfile[127])
{
int fha=0; int fhb=0; int fhc=0; bool myflag=false;
unsigned __int8 buff[7]; int bytrd; unsigned __int8 tmpdata[7];
fha = _open(Infile, _O_BINARY | _O_RDONLY);
fhb = _open(Keyfile, _O_BINARY | _O_RDONLY);
fhc = _open(Outfile, _O_BINARY | _O_WRONLY | _O_CREAT);
_read(fhb, matrix, 8);
do
{
bytrd = _read(fha, buff, 8);
if(!myflag)
{
timesmorphed = buff[3];
myflag = true;
};
for(int m = 0; m <= 7; m++)
{
tmpdata[m] = buff[m] ^ matrix[m];
};
_write(fhc, tmpdata, bytrd);
MatrixMorph();
}
while(_eof(fha)==0);
_close(fha); _close(fhb); _close(fhc);
}
void __stdcall DecryptThis(char Infile[127], char Keyfile[127], char Outfile[127])
{
int fha=0; int fhb=0; int fhc=0; bool myflag=false;
unsigned __int8 buff[7]; int bytrd; unsigned __int8 tmpdata[7];
fha = _open(Infile, _O_BINARY | _O_RDONLY);
fhb = _open(Keyfile, _O_BINARY | _O_RDONLY);
fhc = _open(Outfile, _O_BINARY | _O_WRONLY | _O_CREAT);
_read(fhb, matrix, 8);
do
{
bytrd = _read(fha, buff, 8);
for(int m = 0; m <= 7; m++)
{
tmpdata[m] = buff[m] ^ matrix[m];
};
if(!myflag)
{
timesmorphed = tmpdata[3];
myflag = true;
};
_write(fhc, tmpdata, bytrd);
MatrixMorph();
}
while(_eof(fha)==0);
_close(fha); _close(fhb); _close(fhc);
}
int MatrixMorph(void)
{
__int8 tmp = 0;
if((timesmorphed % 5) == 0)
{
tmp = matrix[1];
for(int n = 0; n <= 7; n++)
{
matrix[n] = matrix[n] ^ tmp;
};
};
if((timesmorphed % 5) == 1)
{
tmp = matrix[4];
for(int n = 0; n <= 7; n++)
{
matrix[n] = matrix[n] & tmp;
};
};
if((timesmorphed % 5) == 2)
{
tmp = matrix[3];
for(int n = 0; n <= 7; n++)
{
matrix[n] = matrix[n] ^ tmp;
};
};
if((timesmorphed % 5) == 3)
{
tmp = matrix[7];
for(int n = 0; n <= 7; n++)
{
matrix[n] = matrix[n] | tmp;
};
};
if((timesmorphed % 5) == 4)
{
tmp = matrix[6];
for(int n = 0; n <= 7; n++)
{
matrix[n] = matrix[n] ^ tmp;
};
};
timesmorphed++;
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -