- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
des.h
资源名称:HookAPI [点击查看]
上传用户:nbcables
上传日期:2007-01-11
资源大小:1243k
文件大小:2k
源码类别:
钩子与API截获
开发平台:
Visual C++
- #ifndef __DES_H
- #define __DES_H
- class DES {
- public:
- // Encrypt/decrypt the data in "data", according to the "key".
- // Caller is responsible for confirming the buffer size of "data"
- // points to is 8*"blocks" bytes.
- // The data encrypted/decrypted is stored in data.
- // The return code is 1:success, other:failed.
- int encrypt ( unsigned char key[8], unsigned char* data, unsigned char *data_out, int blocks = 1 );
- int decrypt ( unsigned char key[8], unsigned char* data, unsigned char *data_out, int blocks = 1 );
- // Encrypt/decrypt any size data,according to a special method.
- // Before calling yencrypt, copy data to a new buffer with size
- // calculated by extend.
- int yencrypt ( unsigned char key[8], unsigned char* data, int size );
- int ydecrypt ( unsigned char key[8], unsigned char* in, int blocks, int* size = 0 );
- int extend ( int size ) { return (size/8+1)*8; };
- private:
- void des(unsigned char* in, unsigned char* out, int blocks);
- void des_block(unsigned char* in, unsigned char* out);
- private:
- unsigned long KnL[32];
- enum Mode { ENCRYPT, DECRYPT };
- void deskey(unsigned char key[8], Mode md);
- void usekey(unsigned long *);
- void cookey(unsigned long *);
- private:
- void scrunch(unsigned char *, unsigned long *);
- void unscrun(unsigned long *, unsigned char *);
- void desfunc(unsigned long *, unsigned long *);
- private:
- static unsigned char Df_Key[24];
- static unsigned short bytebit[8];
- static unsigned long bigbyte[24];
- static unsigned char pc1[56];
- static unsigned char totrot[16];
- static unsigned char pc2[48];
- static unsigned long SP1[64];
- static unsigned long SP2[64];
- static unsigned long SP3[64];
- static unsigned long SP4[64];
- static unsigned long SP5[64];
- static unsigned long SP6[64];
- static unsigned long SP7[64];
- static unsigned long SP8[64];
- };
- #endif