ROT 13
This code performs ROT 13 encryptiontheLazyProgrammer
c_cpp
a year ago
549 B
41
Indexable
/** * rot13 - perform ROT13 encryption * @s: string to encrypt * * Return: pointer to the encrypted string @s */ char *rot13(char *s) { int i, j; const char *map = "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM"; for (i = 0; s[i] != '\0'; i++) { char ch = s[i]; if (ch >= 'a' && ch <= 'z') { j = ch - 'a'; /* get index position for lowercase letters */ s[i] = map[j]; } else if (ch >= 'A' && ch <= 'Z') { j = ch - 'A' + 26; /* get index position for uppercase letters */ s[i] = map[j]; } } return (s); }
Editor is loading...