/* Vigenere cipher * Encryption only. Decryption is the same - * subtraction is used instead of addition. * By Feky */ #include #include int main(int argc, char * argv[]){ int pos, i=0, key, r; char key_buff[255]; if(argc != 3){ printf("Usage: %s [text] [key]\n", argv[0]); return 1; } while(strlen(argv[2]) < strlen(argv[1])){ /* Extend the key */ strcpy(key_buff, argv[2]); strcat(argv[2], key_buff); } while(argv[1][i] != '\0'){ pos = argv[1][i]; key = argv[2][i] - 65; /* Make the key */ if(isupper(pos)){ r = pos + key; if(r > 'Z') r-=26; printf("%c", r); /* Main stuff */ } i++; } return 0; }