现在的位置: 首页 > 综合 > 正文

加密,解密!自娱自乐控制台小程序!

2013年09月10日 ⁄ 综合 ⁄ 共 984字 ⁄ 字号 评论关闭

 

#include "stdafx.h"

#include "stdio.h"   
#include "string.h"   
#include"stdlib.h"   

void Cryptogram();  
void Ansert();  
void Menu();  

void Cryptogram()  
{  
	int result = 1;  
	int i ;  
	int count = 0;  
	char Text[128]={'\0'};  
	char cryptograph[128]={'\0'};  
		printf("请输入要加密的明文:\n");  
	scanf("%s",&Text);  
	count = strlen(Text);  
	for ( i =0;i<count;i++)  
	{  
		cryptograph[i] =Text[i]+i+5;  
	}  
	cryptograph[i] ='\0';  
	printf("加密后的密文是: %s\n",cryptograph);  
	}  

	void Ansert()  
	{  
		int result = 1;  
		int i ;  
		int count = 0;  
		char Text[128]={'\0'};  
		char cryptograph[128]={'\0'};  
			printf("请输入密文:\n");  
		scanf("%s",&cryptograph);  
		count = strlen(cryptograph);  
		for ( i =0;i<count;i++)  
		{  
			Text[i]; cryptograph[i]-i-5;  
		}  
		Text[i] ='\0';  
		printf("解密后的密码是: %s\n",Text);  

		}  


		void Menu()  
		{  
			printf("\t请选择你希望的操作!\n");  
			printf("\t--------------------\n");  
			printf("\t 1.加密处理!\n");  
			printf("\t 2.解密处理! \n");  
			printf("\t 3.退出程序! \n");  

			printf("\t--------------------\n");  
		}  

		int main()  
		{  
			while(1)  
			{  
				Menu();  
				int i;  
				printf("请选择:");  
				scanf("%d",&i);  
				switch(i)  
				{  
				case 1: Cryptogram();  
					break;  
				case 2: Ansert();  
					break;  
				case 3:exit(0);  
				default:  
					printf("选择错误!");  
				}  
				system("pause");  
				system("cls");  
			}  
		} 

抱歉!评论已关闭.