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

📄 data_struct.h

📁 本人基于William Stalling的《密码学与网络安全》实现的128位DES加密算法
💻 H
字号:
//////////////////////////////////////////////////////////////////////////////
//						**************************							//
//						*Data Encryption Standard*							//
//						**************************							//
//																			//
//								Realized in C								//
//																			//
//								*************								//
//								*Constructed*								//
//								*     By    *								//
//								*           *								//
//								*Xie Xingwei*								//
//								*************								//
//																			//
//	If you have any question about my code,contact me with E-mail please	//
//																			//
//						xiexingwei_2008@hotmail.com							//
//////////////////////////////////////////////////////////////////////////////

#ifndef DATA_STRUCT_H
#define DATA_STRUCT_H

struct BLOCK2L /*2-bit data block with only one part*/
{
	unsigned block:2;
};

struct BLOCK2S /*2-bit data block with two equal parts*/
{
	unsigned bit0:1;
	unsigned bit1:1;
};

struct BLOCK4L /*4-bit data block with only one part*/
{
	unsigned block:4;
};

struct BLOCK4S /*4-bit data block with four equal parts*/
{
	unsigned bit0:1;
	unsigned bit1:1;
	unsigned bit2:1;
	unsigned bit3:1;
};

struct BLOCK32L/*32-bit data block with only one part*/
{
	unsigned block:32;
};

struct BLOCK32S8/*32-bit data block with eight equal parts*/
{
	unsigned block0:4;
	unsigned block1:4;
	unsigned block2:4;
	unsigned block3:4;
	unsigned block4:4;
	unsigned block5:4;
	unsigned block6:4;
	unsigned block7:4;
};

struct BLOCK32S/*32-bit data block with 32 equal parts*/
{
	unsigned bit0:1, bit1:1, bit2:1, bit3:1, bit4:1, bit5:1, bit6:1, bit7:1,  \
			 bit8:1, bit9:1, bit10:1,bit11:1,bit12:1,bit13:1,bit14:1,bit15:1, \
			 bit16:1,bit17:1,bit18:1,bit19:1,bit20:1,bit21:1,bit22:1,bit23:1, \
			 bit24:1,bit25:1,bit26:1,bit27:1,bit28:1,bit29:1,bit30:1,bit31:1;
};

struct BLOCK48S/*48-bit data block with 48 equal parts*/
{
	unsigned bit0:1, bit1:1, bit2:1, bit3:1, bit4:1, bit5:1, bit6:1, bit7:1,  \
			 bit8:1, bit9:1, bit10:1,bit11:1,bit12:1,bit13:1,bit14:1,bit15:1, \
			 bit16:1,bit17:1,bit18:1,bit19:1,bit20:1,bit21:1,bit22:1,bit23:1, \
			 bit24:1,bit25:1,bit26:1,bit27:1,bit28:1,bit29:1,bit30:1,bit31:1, \
			 bit32:1,bit33:1,bit34:1,bit35:1,bit36:1,bit37:1,bit38:1,bit39:1, \
			 bit40:1,bit41:1,bit42:1,bit43:1,bit44:1,bit45:1,bit46:1,bit47:1;
};

struct SUBKEYSTRUCT /*The 48-bit subkey generated from the 56-bit key*/
{
	unsigned k0:1, k1:1, k2:1, k3:1, k4:1, k5:1, k6:1, k7:1,  \
			 k8:1, k9:1, k10:1,k11:1,k12:1,k13:1,k14:1,k15:1, \
			 k16:1,k17:1,k18:1,k19:1,k20:1,k21:1,k22:1,k23:1, \
			 k24:1,k25:1,k26:1,k27:1,k28:1,k29:1,k30:1,k31:1, \
			 k32:1,k33:1,k34:1,k35:1,k36:1,k37:1,k38:1,k39:1, \
			 k40:1,k41:1,k42:1,k43:1,k44:1,k45:1,k46:1,k47:1;
};

struct BLOCK64S/*64-bit data block with 64 equal parts*/
{
	unsigned bit0:1, bit1:1, bit2:1, bit3:1, bit4:1, bit5:1, bit6:1, bit7:1,  \
			 bit8:1, bit9:1, bit10:1,bit11:1,bit12:1,bit13:1,bit14:1,bit15:1, \
			 bit16:1,bit17:1,bit18:1,bit19:1,bit20:1,bit21:1,bit22:1,bit23:1, \
			 bit24:1,bit25:1,bit26:1,bit27:1,bit28:1,bit29:1,bit30:1,bit31:1, \
			 bit32:1,bit33:1,bit34:1,bit35:1,bit36:1,bit37:1,bit38:1,bit39:1, \
			 bit40:1,bit41:1,bit42:1,bit43:1,bit44:1,bit45:1,bit46:1,bit47:1, \
			 bit48:1,bit49:1,bit50:1,bit51:1,bit52:1,bit53:1,bit54:1,bit55:1, \
			 bit56:1,bit57:1,bit58:1,bit59:1,bit60:1,bit61:1,bit62:1,bit63:1;
};

struct KEYSTRUCT /*The original 64-bit key*/
{
	unsigned k0:1, k1:1, k2:1, k3:1, k4:1, k5:1, k6:1, k7:1,  \
			 k8:1, k9:1, k10:1,k11:1,k12:1,k13:1,k14:1,k15:1, \
			 k16:1,k17:1,k18:1,k19:1,k20:1,k21:1,k22:1,k23:1, \
			 k24:1,k25:1,k26:1,k27:1,k28:1,k29:1,k30:1,k31:1, \
			 k32:1,k33:1,k34:1,k35:1,k36:1,k37:1,k38:1,k39:1, \
			 k40:1,k41:1,k42:1,k43:1,k44:1,k45:1,k46:1,k47:1, \
			 k48:1,k49:1,k50:1,k51:1,k52:1,k53:1,k54:1,k55:1, \
			 k56:1,k57:1,k58:1,k59:1,k60:1,k61:1,k62:1,k63:1;
};

#endif /*DATA_STRUCT_H*/

⌨️ 快捷键说明

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