当前位置:网站首页>Implementation of Caesar cipher

Implementation of Caesar cipher

2020-11-07 20:19:00 PamShao

#include <stdio.h>

int main()
{
	//  Caesar encryption , The letters in plaintext are shifted three places to the left or right of the alphabet , Move right here 
	char input[6] = "hello";
	char output[6];
	int key = 3;
	int i,j;
	for (i = 0; i < 5; i++)
	{
		int a = input[i];
		a += 3;
		output[i] = (char)a;
	}
	output[i] = '\0';
	printf(" After encryption :%s\n", output);

	for (j = 0; j < 5; j++)
	{
		int b = output[j];
		b -= 3;
		input[j] = (char)b;
	}
	input[j] = '\0';
	printf(" After decryption :%s", input);
	return 0;
}  

版权声明
本文为[PamShao]所创,转载请带上原文链接,感谢