Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Function decrypts a cipher with key n. (Flips the word before.)
- input: string cipher, int n.
- output: none.
- */
- void decrypt(char* cipher, int n)
- {
- int i = 0;
- char newStr[SIZE] = { 0 };
- while (*(cipher + i) != '\0')
- {
- // This line is crazy... It gets the i left most char removes 'a' from it adds the key n and module it by 26 and returns the 'a'.
- *(newStr + i) = 'a' + ((*((cipher + (strlen(cipher) - 1)) - i) - 'a' + n) % ABC_SIZE);
- i++;
- }
- strcpy(cipher, newStr);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement