📄 dodes.h
字号:
/////////////////////////////////////////////
// File name: ENCDEC.H
// for Class CEncDec
// algrithom for DES ( data encryption standard)
//
// used to encryption and decryption a segment of memory
// Interface:
// setKey(char *s)
// -----Set key for encryption or decrption
// doEncryption(void *p,long size)
// -----to encryption an area of memory p, length is size
// doDecryption(void *p,long size)
// ----- see upper
//#include "c:\0\type.h" //only for test class on console mode
#include "stdafx.h"
#ifndef SINMIN_DES_HEAD_FILE_12343245 // to assume only
#define SINMIN_DES_HEAD_FILE_12343245 //include once
#define MAXKEYLENGTH 32
enum { ERR_ALLOCATEMEMORY=1, // allocte memory error
ERR_LENGTH, // encryption length not 8*X
ERR_UNKNOW // unknow error
};
class CDES
{
BOOL initializeDES(void); //initialize, allocate memory,calcu tables....
__int64 bitTable[64]; //1,2,4,8,16... only a bit is 1
char key[8]; //Key
__int64 subKey[16]; //16 sub-keys, 64bits each, 48bits
//really used
void calculateSubKey(void);
char *pTable;
int errorNumber;
void runCircle(char *dat, int iTms);
char cv6to4(int tabNumber,char vu);
//__int64 getBit(int pos);
__int64 shuffle(__int64 d,char *p);
__int64 shuffle32(__int64 d);
__int64 expand(__int64 x); //convert 32 bits to 48 bits
__int64 deflate(__int64 x); //convert 48bits to 32bits
public:
//CDES();
CDES(char *key=NULL); // constructor
~CDES(); //destructor
int setKey(char *s);
int encryption(void *p,DWORD size);
int decryption(void *p,DWORD size);
int getErrorNumber(void);
char *getErrorDescription(int errNum);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -