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

📄 desecb.c

📁 这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易于我们学习和理解
💻 C
字号:
#include "os.h"#include <mp.h>#include <libsec.h>// I wasn't sure what to do when the buffer was not// a multiple of 8.  I did what lacy's cryptolib did// to be compatible, but it looks dangerous to me// since its encrypting plain text with the key. -- presottovoiddesECBencrypt(uchar *p, int len, DESstate *s){	int i;	uchar tmp[8];	for(; len >= 8; len -= 8){		block_cipher(s->expanded, p, 0);		p += 8;	}		if(len > 0){		for (i=0; i<8; i++)			tmp[i] = i;		block_cipher(s->expanded, tmp, 0);		for (i = 0; i < len; i++)			p[i] ^= tmp[i];	}}voiddesECBdecrypt(uchar *p, int len, DESstate *s){	int i;	uchar tmp[8];	for(; len >= 8; len -= 8){		block_cipher(s->expanded, p, 1);		p += 8;	}		if(len > 0){		for (i=0; i<8; i++)			tmp[i] = i;		block_cipher(s->expanded, tmp, 0);		for (i = 0; i < len; i++)			p[i] ^= tmp[i];	}}

⌨️ 快捷键说明

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