Vernam加密法:
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <sstream>
#include <time.h>
using namespace std;
char clear_text[10000];
string ans;
char key[10000];
int main()
{
memset(key, 0, sizeof(key));
ans.clear();
printf("please enter the clear_text :");
scanf("%s", clear_text);
int len = strlen(clear_text);
printf("please enter key :");
scanf("%s", &key);
for (int i = 0;i < len;i++)
{
int tmp = (clear_text[i] - 'a' + key[i] - 'a') % 26;
ans += (char)(tmp + 'a');
}
<