今天终于把DES加密算法中的IP置换和其逆置换搞定了,两个算法是一样的,只是置换表的不同而已.测试通过^_^.
在此记录下,供以后自己参考或同样喜欢C编程的人参考.
以前C程序写的少,今后会一直写下去,写完DES再尝试一下其它的加密算法
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef unsigned int MYINT32;
typedef struct block
{
MYINT32 left32; //存储高32bit
MYINT32 right32;//存储低32bit
}BLOCK;
static void _IP(BLOCK *p)
{
BLOCK plntxt = {0,0};
MYINT32 i, ip[]=
{
58, 50, 42, 34, 26, 18, 10, 2,
60, 52, 44, 36, 28, 20, 12, 4,
62, 54, 46, 38, 30, 22, 14, 6,
64, 56, 48, 40, 32, 24, 16, 8,
57, 49, 41, 33, 25, 17, 9, 1,
59, 51, 43, 35, 27, 19, 11, 3,
61, 53, 4