📄 bbs水木清华站∶精华区h.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0090)http://www.library.nenu.edu.cn/smthbbs.991022/Hacker.html/Hacker.AIX/00000116/00000002.htm -->
<HTML><HEAD><TITLE>BBS水木清华站∶精华区</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY>
<CENTER>
<H1>BBS水木清华站∶精华区</H1></CENTER>发信人: orbix (小鱼), 信区: Hacker <BR>标 题: DES源程序之头文件 <BR>发信站: BBS 水木清华站 (Mon Apr 20 22:53:30 1998) <BR> <BR>自己改写过,请指教 <BR>#ifndef __DES_H <BR>#define __DES_H <BR> <BR>class DES <BR>{ <BR>public: <BR> // Encrypt/decrypt the data in "data", according to the "key". <BR> // Caller is responsible for confirming the buffer size of "data" <BR> // points to is 8*"blocks" bytes. <BR> // The data encrypted/decrypted is stored in data. <BR> // The return code is 1:success, other:failed. <BR> int encrypt ( char key[8], char* data, int blocks = 1 ); <BR> int decrypt ( char key[8], char* data, int blocks = 1 ); <BR> <BR> // Encrypt/decrypt any size data,according to a special method. <BR> // Before calling yencrypt, copy data to a new buffer with size <BR> // calculated by extend. <BR> int yencrypt ( char key[8], char* data, int size ); <BR> int ydecrypt ( char key[8], char* in, int blocks, int* size = 0 ); <BR> <BR> int extend ( int size ) { return (size/8+1)*8; }; <BR> <BR>private: <BR> void des(unsigned char* in, unsigned char* out, int blocks); <BR> void des_block(unsigned char* in, unsigned char* out); <BR> <BR>private: <BR> unsigned long KnL[32]; <BR> enum Mode { ENCRYPT, DECRYPT }; <BR> void deskey(unsigned char key[8], Mode md); <BR> void usekey(unsigned long *); <BR> void cookey(unsigned long *); <BR> <BR>private: <BR> void scrunch(unsigned char *, unsigned long *); <BR> void unscrun(unsigned long *, unsigned char *); <BR> void desfunc(unsigned long *, unsigned long *); <BR> <BR>private: <BR> static unsigned char Df_Key[24]; <BR> static unsigned short bytebit[8]; <BR> static unsigned long bigbyte[24]; <BR> static unsigned char pc1[56]; <BR> static unsigned char totrot[16]; <BR> static unsigned char pc2[48]; <BR> static unsigned long SP1[64]; <BR> static unsigned long SP2[64]; <BR> static unsigned long SP3[64]; <BR> static unsigned long SP4[64]; <BR> static unsigned long SP5[64]; <BR> static unsigned long SP6[64]; <BR> static unsigned long SP7[64]; <BR> static unsigned long SP8[64]; <BR> <BR>}; <BR> <BR>#endif <BR> <BR>-- <BR>※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: cit.cs.sjtu.edu] <BR>
<CENTER>
<H1>BBS水木清华站∶精华区</H1></CENTER></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -