#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
#define MAX_LEN 1000000
static int f(int i);
static int index(int c);
void encrypt(char *str);
char str_buffer[MAX_LEN];
int main(int argc, char *argv[])
{
while(scanf("%s", str_buffer) != EOF) {
encrypt(str_buffer);
printf("%s", str_buffer);
}
/*
scanf("%s", str_buffer);
encrypt(str_buffer);
printf("%s", str_buffer);
*/
return 0;
}
void encrypt(char *str) {
//static char alphbelt[] = "ZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY";
static char *alphbelt = "ZabcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXY";
while(*str) {
*str++ = alphbelt[index(*str)];
}
}
static int index(int c){
assert(isalpha(c));
if(isupper(c)) {
c = c - 'A' + 27;
}else if(islower(c)){
c = c - 'a' + 1;
}else {
printf("These is some non alphbet letter!\n");
exit(1);
}
c = f(c) % 52;
return c;
}
static int f(int i) {
return i*i + i + 1;
}
单词加密
最新推荐文章于 2021-02-25 14:31:59 发布