内存:128  时间:1

题目描述

输入

输出

样例输入

样例输出

提示

代码如下

#include<stdio.h>
void encrypt();
void decrypt();
int xunhuanzuoyi(int x);
int xunhuanyouyi(int x);
int main()
{
    encrypt();
    decrypt();	
    return 0;
}
void encrypt()
{
	unsigned char k1,k2,k3,a1,a2,a3,a4,a5,a6,a7,a8;
	int t,m,n;
	printf("PLEASE INPUT YOUR KEY:
");
	scanf("%c%c%c%*c",&k1,&k2,&k3);
	t=xunhuanzuoyi(k1);
	m=k2;
	n=xunhuanyouyi(k3);
	printf("PLEASE INTPUT YOUR ENCRYPTED PASSWORD:
");
	scanf("%c %c %c %c %c %c %c %c%*c",&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8);
	a1=a1^t;
	a4=a4^t;
	a7=a7^t;
	a2=a2^m;
	a5=a5^m;
	a8=a8^m;
	a3=a3^n;
	a6=a6^n;
	printf("%d %d %d %d %d %d %d %d
",a1,a2,a3,a4,a5,a6,a7,a8);
}
void decrypt()
{
	unsigned char k4,k5,k6,a1,a2,a3,a4,a5,a6,a7,a8;
	int t,m,n;
	printf("PLEASE INPUT YOUR KEY:
");
	scanf("%c%c%c%*c",&k4,&k5,&k6);
	t=xunhuanzuoyi(k4);
	m=k5;
	n=xunhuanyouyi(k6);
	printf("PLEASE INTPUT YOUR DECRYPTED PASSWORD:
");
	scanf("%d %d %d %d %d %d %d %d%*c",&a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8);
	a1=a1^t;
	a4=a4^t;
	a7=a7^t;
	a2=a2^m;
	a5=a5^m;
	a8=a8^m;
	a3=a3^n;
	a6=a6^n;
	printf("%c%c%c%c%c%c%c%c
",a1,a2,a3,a4,a5,a6,a7,a8);

}
int xunhuanzuoyi(int x)
{
	unsigned char a,b;
	a=x>>5;
	b=x<<3;
	return (a|b);
}
int xunhuanyouyi(int x)
{
	unsigned char a,b;
	a=x<<5;
	b=x>>3;
	return (a|b);
}

代码来源于互联网,仅供参考!