文本加密小程序
查看原帖
文本加密小程序
154952
我是一个蒟蒻楼主2021/3/13 17:18

RT

#include<bits/stdc++.h>
#include<windows.h>
const int aABC=24;
const int abc=154952; 
using namespace std;
int main()
{
	int n,a[10005];
	string s;
	system("cls");
	printf("文本加密小程序V1.00 by abcd\n");
	printf("目前支持中文、英文、数字、字符(不能有$)\n");
	printf("目前空格会丢,正在修复\n");
	printf("请先在目录下新建text.txt和password.txt\n");
	printf("在text.txt中输入要加密的文字,用$结尾,按1,就可以在password.txt中查看密文\n");
	printf("或在password.txt中输入要解密的文字,按2,就可以在text.txt中查看解密的文字\n");
	printf("如有问题请找https://www.luogu.com.cn/user/154952\n");
	printf("1:加密\n");
	printf("2:解密\n");
	printf("0:退出\n");
	printf("\n\n请输入:");
	scanf("%d",&n);
	switch(n)
	{
		case 0:
		{
			return 0;
			break;
		}
		case 1:
		{
			system("cls");
			freopen("text.txt","r",stdin);
			freopen("password.txt","w",stdout);
			char c;
			while(scanf("%c",&c) && c!='$')
			{
				if(c!=' ')
				{
					printf("%d ",(int(c)*aABC-abc));
				}
			}
			printf("154952");
			fclose(stdin);
			fclose(stdout);
		}
		case 2:
		{
			system("cls");
			freopen("text.txt","w",stdout);
			freopen("password.txt","r",stdin);
			int a;
			while(scanf("%d",&a) && a!=154952)
			{
				printf("%c",char((a+abc)/aABC));
			}
			printf("$");
			fclose(stdin);
			fclose(stdout);
		}
	}
	return 0;
}

小蒟蒻写的,大佬勿喷

2021/3/13 17:18
加载中...