问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

求C或C++的DES加密算法

发布网友 发布时间:2022-04-24 18:24

我来回答

1个回答

热心网友 时间:2023-10-31 20:35

/* d3des.h -
*
* Headers and defines for d3des.c
* Graven Imagery, 1992.
*
* Copyright (c) 1988,1989,1990,1991,1992 by Richard Outerbridge
* (GEnie : OUTER; CIS : [71755,204])
*/

#define D2_DES /* include double-length support */
#define D3_DES /* include triple-length support */

#ifdef D3_DES
#ifndef D2_DES
#define D2_DES /* D2_DES is needed for D3_DES */
#endif
#endif

#define EN0 0 /* MODE == encrypt */
#define DE1 1 /* MODE == decrypt */

/* A useful alias on 68000-ish machines, but NOT USED HERE. */

typedef union {
unsigned long blok[2];
unsigned short word[4];
unsigned char byte[8];
} M68K;

extern void deskey(unsigned char *, short);
/* hexkey[8] MODE
* Sets the internal key register according to the hexadecimal
* key contained in the 8 bytes of hexkey, according to the DES,
* for encryption or decryption according to MODE.
*/

extern void usekey(unsigned long *);
/* cookedkey[32]
* Loads the internal key register with the data in cookedkey.
*/

extern void cpkey(unsigned long *);
/* cookedkey[32]
* Copies the contents of the internal key register into the storage
* located at &cookedkey[0].
*/

extern void des(unsigned char *, unsigned char *);
/* from[8] to[8]
* Encrypts/Decrypts (according to the key currently loaded in the
* internal key register) one block of eight bytes at address 'from'
* into the block at address 'to'. They can be the same.
*/

#ifdef D2_DES

#define desDkey(a,b) des2key((a),(b))
extern void des2key(unsigned char *, short);
/* hexkey[16] MODE
* Sets the internal key registerS according to the hexadecimal
* keyS contained in the 16 bytes of hexkey, according to the DES,
* for DOUBLE encryption or decryption according to MODE.
* NOTE: this clobbers all three key registers!
*/

extern void Ddes(unsigned char *, unsigned char *);
/* from[8] to[8]
* Encrypts/Decrypts (according to the keyS currently loaded in the
* internal key registerS) one block of eight bytes at address 'from'
* into the block at address 'to'. They can be the same.
*/

extern void D2des(unsigned char *, unsigned char *);
/* from[16] to[16]
* Encrypts/Decrypts (according to the keyS currently loaded in the
* internal key registerS) one block of SIXTEEN bytes at address 'from'
* into the block at address 'to'. They can be the same.
*/

extern void makekey(char *, unsigned char *);
/* *password, single-length key[8]
* With a double-length default key, this routine hashes a NULL-terminated
* string into an eight-byte random-looking key, suitable for use with the
* deskey() routine.
*/

#define makeDkey(a,b) make2key((a),(b))
extern void make2key(char *, unsigned char *);
/* *password, double-length key[16]
* With a double-length default key, this routine hashes a NULL-terminated
* string into a sixteen-byte random-looking key, suitable for use with the
* des2key() routine.
*/

#ifndef D3_DES /* D2_DES only */

#define useDkey(a) use2key((a))
#define cpDkey(a) cp2key((a))

extern void use2key(unsigned long *);
/* cookedkey[64]
* Loads the internal key registerS with the data in cookedkey.
* NOTE: this clobbers all three key registers!
*/

extern void cp2key(unsigned long *);
/* cookedkey[64]
* Copies the contents of the internal key registerS into the storage
* located at &cookedkey[0].
*/

#else /* D3_DES too */

#define useDkey(a) use3key((a))
#define cpDkey(a) cp3key((a))

extern void des3key(unsigned char *, short);
/* hexkey[24] MODE
* Sets the internal key registerS according to the hexadecimal
* keyS contained in the 24 bytes of hexkey, according to the DES,
* for DOUBLE encryption or decryption according to MODE.
*/

extern void use3key(unsigned long *);
/* cookedkey[96]
* Loads the 3 internal key registerS with the data in cookedkey.
*/

extern void cp3key(unsigned long *);
/* cookedkey[96]
* Copies the contents of the 3 internal key registerS into the storage
* located at &cookedkey[0].
*/

extern void make3key(char *, unsigned char *);
/* *password, triple-length key[24]
* With a triple-length default key, this routine hashes a NULL-terminated
* string into a twenty-four-byte random-looking key, suitable for use with
* the des3key() routine.
*/

#endif /* D3_DES */
#endif /* D2_DES */

参考资料:http://zhidao.baidu.com/question/1543228.html?si=3

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
十二生肖中哪些代表达官显贵 宋小宝《吃面》,汤面换炒面,不给钱,怎么破 在职研究生的双证是哪两个证? 在读研究生双证有哪些 研究生双证是什么 吃什么对肝脏好处最大 咳嗽挂哪科 复读生高考结束后档案袋到哪领 复读生档案 收到了录取通知书,而选择复读,但档案袋在自己那里,对明年高考有影 复刻表是什么? D-Link DES-1226G在网上看说可以做VLAN配置 有谁会做啊? 界面是E文的 DES是什么意思??跪求!速度!很急! 搞不懂复刻表和原单手表的区别? DES是什么意思? 复刻表和真品区别在哪? 法语中的des和de有什么区别分别怎么用呀? 复刻表和正品表的区别在哪? D-LINK 友讯DES-1228交换机 如何进入配置? 路由器 D-LINK DES-1005D 可不可以使iphone上wifi 复刻表与正品手表的区别是什么? D-Link DES-1026G的参数 正品和复刻有什么区别,原装正品表和复刻表有什么区别 D-LINK DES-1005D五端口以太网交换机怎么用? 【详细点】 复刻表和原单手表的区别是什么? 路由器 D-LINK DES-1005D 要如何设置?? 原单手表和复刻表的区别是什么? D-Link DES-1024R 如何使用 使用之前需要设置吗 例如ip D-LinkDES-1016D怎么设置上网? D-LINK DES-3052交换机如何确定收到ARP攻击 des加密算法(c/c++) 如何区分高仿表和复刻表? 精仿表和复刻表的区别? 原单表,复刻表什么意思,值得买吗,这个1350 杜康大曲是粮食酒吗 可以将手机游戏包括声音投屏到智能电视上面吗,怎么弄 杜康酒是粮食酒吗白酒浓香型好还是酱香型好? 什么是一比一复刻表,与原版有什么区别? 苹果手机为什么电视投屏后打游戏时游戏声音在电视上 20--30元的杜康酒真的是粮食酒吗? 请问奶茶的珍珠属于什么垃圾? 怎么把手游投屏到电视上,而且要有声音 杜康老窖青花瓷是粮食酒吗 手机游戏声音同步到电脑 如图所示:杜康酒是什么酒(酱香和清香)啊? 奶茶的珍珠就是西米吗? 珍珠奶茶里的珍珠是什么?是否有害健康? 华为手机游戏投屏到电视 想把手机游戏投屏到电视上玩,有哪几种方法? 奶茶的里的珍珠是什么材料?