加密一个密码程序
- 提问者网友:做自己de王妃
- 2021-05-17 15:50
- 五星知识达人网友:長槍戰八方
- 2021-05-17 17:28
int i,liuweishu,xx;
int a[5],b[5];
printf("请输入一个六位数:");
scanf("%d",&liuweishu);
for (i=0;i<6;i++)
{
xx=0;
for (j=0;j<=i;j++)
xx=xx*10;
b[i]=(liuweishu/(xx)%(100000/xx)+5)%10; //b数组用于暂存这六个数
}
for (i=0;i<6;i++)
a[i]=b[5-i]; //调换位置后存入a数组中
- 1楼网友:上分大魔王
- 2021-05-17 18:43
#include <stdio.h> #include <iostream> #include <stdlib.h> #include <time.h> #include <math.h>
void Encryption(void ) {
int i ,temp; long dest = 0; int itr_ptr[6];//起初的6位数 int itr_adess[6];//加模后的6位数 int itr_return[6];//变换位置后的数 bool bIsChange[6] = {0,0,0,0,0,0}; static int index = 0; printf("please press in 6 number"); for (i=0 ; i<6; i++) { scanf("%d",&itr_ptr[i]); } printf("plase wait\n");
for (i=0;i<6;i++) { itr_adess[i] = (itr_ptr[i]+5)%10 ; }
while(index<6) { time_t t; srand((unsigned) time(&t));
temp = rand()%6;
if(bIsChange[temp]==0) { itr_return[index] = itr_adess[temp]; bIsChange[temp] = 1; index ++; } } for (i=0;i<6;i++) { dest += itr_return[i] * (int)pow((double )10,(double )i); }
printf("%d",dest); while(1);
}
main()
{
Encryption();
}