DES算法,头文件

DES算法,头文件


自己改写过,请指教
#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 ( 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* 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


中华技术网整理发布 http://www.asfocus.com http://www.netqu.com

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值