📄 sdes.cpp
字号:
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#include <graphics.h>
#include <string.h>
/* initial permutation IP */
static byte ip[] = {
2, 6, 3, 1, 4, 8, 5, 7
};
/* final permutation IP^-1 */
static byte fp[] = {
4, 1, 3, 5, 7, 2, 8, 6
};
/* expansion operation matrix */
static byte ei[] = {
4, 1, 2, 3, 2, 3, 4, 1
};
/* The (in)famous S-boxes */
static byte sbox[2][16] = {
/* S1 */
1, 0, 3, 2, 3, 2, 1, 0, 0, 2, 1, 3, 3, 1, 3, 2,
/* S2 */
0, 1, 2, 3, 2, 0, 1, 3, 3, 0, 1, 0, 2, 1, 0, 3
};
/* 32-bit permutation function P used on the output of the S-boxes */
static byte p32i[] = {
2, 4, 3, 1
};
#endif
/* permuted choice table (key) */
static const byte pc1[] = {
3, 5,2,7,4,10,1,9,8,6
};
/* number left rotations of pc1 */
static const byte totrot[] = {
1,2
};
/* permuted choice key (table) */
static const byte pc2[] = {
6,3,7,4,8,5,10,9
};
/* End of DES-defined tables */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -