You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
the_difference_analysis_of_des/analysis table.h

143 lines
4.5 KiB

#ifndef TASK1_H_INCLUDED
#define TASK1_H_INCLUDED
#include<stdio.h>
#include<stdlib.h>
void hello() {
printf("fsdf");
}
int mainFuntion(int in[6]) {
int In[6];
for (int i = 0; i < 6; i++) {
In[i] = in[i];
} //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
int k;
//int i;
void Differ(int In[6]); //fp<66><70>ָ<EFBFBD><EFBFBD><EBA3AC><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>FILE<4C><45><EFBFBD>͵Ķ<CDB5><C4B6><EFBFBD><EFBFBD><EFBFBD>
void s_box(int array[6], int brray[4], int crray[4][16]); //<2F><><EFBFBD><EFBFBD>des<65>ѽ<EFBFBD><D1BD><EFBFBD>д<EFBFBD><D0B4>8<EFBFBD><38>6<EFBFBD><36><EFBFBD>ش<EFBFBD><D8B4>IJ<EFBFBD><C4B2><EFBFBD><EFBFBD><EFBFBD>ÿһ<C3BF><D2BB>s<EFBFBD>а<EFBFBD>6<EFBFBD><36><EFBFBD><EFBFBD>ӳ<EFBFBD>䵽4<E4B5BD><34><EFBFBD><EFBFBD>
//<2F><>array<61><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD>6λ brray<61><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ش<EFBFBD><D8B4><EFBFBD><34><CEBB>crray<61><79>s<EFBFBD><73>4X16
printf("<EFBFBD><EFBFBD><EFBFBD>ֲַ<EFBFBD>ͳ<EFBFBD>Ʊ<EFBFBD>\n");
printf("\n<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: ");
for (k = 0; k <= 5; k++) { //<2F><>ӡ<EFBFBD><D3A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
printf("%d", In[k]);
}
printf("\n");
Differ(In); //<2F><><EFBFBD>ò<EFBFBD><C3B2>ַ<EFBFBD><D6B7><EFBFBD>
return 0;
}
void Differ(int In[6])
{ //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>s<EFBFBD>У<EFBFBD><D0A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѧԭ<D1A7><D4AD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>P76ҳS1
int s[4][16] = { {14,4,13,1,2,15,11,8,3,10,6,12,5,9,0,7}
,{0,15,7,4,14,2,13,1,10,6,12,11,9,5,3,8}
,{4,1,14,8,13,6,2,11,15,12,9,7,3,10,5,0}
,{15,12,8,2,4,9,1,7,5,11,3,14,10,0,6,13}
};
int b[6]; //<2F><><EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
int d[6];
int e[4], f[4], Out[4], n[4];//n[4]<5D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0000~1111<31><31>
int flag;
int l;
int k;
int i, j;
int count; //<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void s_box(int array[6], int brray[4], int crray[4][16]);
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
printf("S1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\t<EFBFBD><EFBFBD><EFBFBD>ܵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
for (i = 0; i <= 15; i++)
{
{
int t; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
t = i; //<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0000~1111<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD><6E>
n[3] = t % 2; t = t / 2;
n[2] = t % 2; t = t / 2;
n[1] = t % 2; t = t / 2;
n[0] = t % 2;
}
//printf("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:");
for (k = 0; k <= 3; k++) //<2F><>ӡ<EFBFBD><D3A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
printf("%d", n[k]);
}
printf("\t\t");
count = 0; //<2F><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>ʼ<EFBFBD><CABC>Ϊ0<CEAA><30>
for (j = 0; j <= 63; j++) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԫ<EFBFBD><D4AA>
{
{ int t;
t = j;
b[5] = t % 2; t = t / 2;
b[4] = t % 2; t = t / 2;
b[3] = t % 2; t = t / 2;
b[2] = t % 2; t = t / 2;
b[1] = t % 2; t = t / 2;
b[0] = t % 2;
}
for (l = 0; l <= 5; l++)
d[l] = b[l] ^ In[l]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>а<EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x<EFBFBD><78>Ӧ<EFBFBD><D3A6>x*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>d[]<5D><>
s_box(b, e, s); //b<><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD>x <20><>e<EFBFBD><65>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊbʱ<62><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
s_box(d, f, s); //d<><64>b<EFBFBD><62><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊin[l]<5D><>Ӧ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>x*<2A><>f<EFBFBD><66>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊbʱ<62><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
for (k = 0; k <= 3; k++)
Out[k] = e[k] ^ f[k]; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֣<EFBFBD><D6A3><EFBFBD><EFBFBD><EFBFBD>Out<75><74><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
flag = 1; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>־λ<D6BE><CEBB>1<EFBFBD><31>
for (k = 0; k <= 3; k++)
{
if (Out[k] != n[k])
{
flag = 0;
break;
}
}
if (flag == 1) {//<2F><><EFBFBD>ϵ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>ʱ<EFBFBD>򣬵<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵļ<D6B5><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ
count = count + 1;
for (int z = 0; z < 6; z++) {
printf("%d", b[z]);
}
printf(",");
}
}
if (count == 0)
printf("û<EFBFBD>п<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
else
printf("\t<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>%d", count);
printf("\n");
}
printf("<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>\n");
}
void s_box(int array[6], int brray[4], int crray[4][16])
{
int p, q, t;
p = 2 * array[0] + array[5]; //<2F><>b1b6<62><36><EFBFBD>ؾ<EFBFBD><D8BE><EFBFBD>s<EFBFBD>е<EFBFBD><D0B5><EFBFBD>ȡֵΪp
q = 2 * 2 * 2 * array[1] + 2 * 2 * array[2] + 2 * array[3] + array[4]; //<2F><>b2b3b4b5<62><35><EFBFBD><EFBFBD>s<EFBFBD>е<EFBFBD><D0B5><EFBFBD>ȡֵΪq
t = crray[p][q]; //t<><74><EFBFBD><EFBFBD>s<EFBFBD><73><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊarray[6]ʱ<><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
brray[3] = t % 2;
t = t / 2;
brray[2] = t % 2;
t = t / 2;
brray[1] = t % 2;
t = t / 2;
brray[0] = t % 2; //<2F><><74><D7AA><EFBFBD>ɶ<EFBFBD><C9B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>brray<61><79>
}
#endif // TASK1_H_INCLUDED
#pragma once