温馨提示×

如何用c语言进行数据加密

九三
686
2021-02-25 14:17:10
栏目: 网络安全

如何用c语言进行数据加密

使用c语言对数据进行加密,具体方法如下:

#include

void main()

{

int a[5];

int num, temp, encripy;

int i;

do

{

printf("Please input the number:");

scanf("%d",&num);

if(!(num/10000 !=0 && num/100000==0))

printf("Data error!\n");

}while(!(num/10000 !=0 && num/100000==0));

a[0] = num/10000%10;

a[1] = num/1000%10;

a[2] = num/100%10;

a[3] = num/10%10;

a[4] = num%10;

for(i = 0; i < 5; ++i)

a[i] = (a[i] + 8)%10;

temp = a[0];

a[0] = a[3];

a[3] = temp;

temp = a[1];

a[1] = a[2];

a[2] = temp;

encripy = a[0]*10000 + a[1]*1000 + a[2]*100 + a[3]*10 + a[4];

printf("\nThe scourse number: %d\n", num);

printf("\nEncripy the number: %d\n\n", encripy);

}

0