DES algorithm, header file

zhaozj2021-02-08  228

DES algorithm, header files have been rewritten, please advise #ifndef __des_h #define __des_h class des {public: // encrypt / decrypt the data in "table", accounting to the "key". // Caller is responsible for confirming the buffer Size of "data" // Points to is 8 * "blocks" bytes. // the data encrypted / decrypted is store in data. // the return code is 1: Success, Other: failed. Int Encrypt (char key [8 ], CHAR * DATA, INT blocks = 1); int Decrypt (Char Key [8], Char * Data, 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 (char key [8], char * data, int size); int yDecrypt (char key [8], char * in, int blocks, int in * size = 0); int extend (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 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];

转载请注明原文地址:https://www.9cbs.com/read-1541.html

New Post(0)