⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdes.h

📁 DES算法程序编程介绍
💻 H
字号:
// CDes.h: interface for the CDes class.
//
//////////////////////////////////////////////////////////////////////

#if !defined(AFX_CDES_H__27D8EC17_5B2E_4070_A855_9BF641E0E61B__INCLUDED_)
#define AFX_CDES_H__27D8EC17_5B2E_4070_A855_9BF641E0E61B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
typedef bool    (*PSubKey)[16][48];
enum    {ENCRYPT,DECRYPT};
static bool SubKey[2][16][48];// 16圈子密钥
static bool Is3DES;// 3次DES标志
static char Tmp[256], deskey[16];

class CDes  
{
public:
	CDes();
	virtual ~CDes();

bool DoDes(char *Out, char *In, long datalen, const char *Key, int keylen, bool Type);
private:
void DES(char Out[8], char In[8], const PSubKey pSubKey, bool Type);//标准DES加/解密
void SetKey(const char* Key, int len);// 设置密钥
void SetSubKey(PSubKey pSubKey, const char Key[8]);// 设置子密钥
void F_func(bool In[32], const bool Ki[48]);// f 函数
void S_func(bool Out[32], const bool In[48]);// S 盒代替
void Transform(bool *Out, bool *In, const char *Table, int len);// 变换
void Xor(bool *InA, const bool *InB, int len);// 异或
void RotateL(bool *In, int len, int loop);// 循环左移
void ByteToBit(bool *Out, const char *In, int bits);// 字节组转换成位组
void BitToByte(char *Out, const bool *In, int bits);// 位组转换成字节组

//////////////////////////////////////////////////////////////////////////
};

#endif // !defined(AFX_CDES_H__27D8EC17_5B2E_4070_A855_9BF641E0E61B__INCLUDED_)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -