The following program (written in C++) creates a filter program for converting ascii into ROT13 encoding. A very simple cypher where each character in the alphabet is replaced with the 13th letter from its position. To download a compiled windows compatible binary, click here.
#include <cstring>
#include <cstdio>
#include <cctype>
using namespace std;
char translate(char c)
{
int cflag = 0;
char oc = c;
char alphabet[] = "abcdefghijklmnopqrstuvwxyz";
int alphalen = strlen(alphabet);
if(isalpha(c)) {
if(isupper(c)) {
cflag = 1;
c = tolower(c);
}
for(int i=0;i<alphalen; ++i) {
if(c==alphabet[i]) {
oc = alphabet[(i+13)%alphalen];
}
}
if(cflag==1) {
oc = toupper(oc);
}
}
return oc;
}
int main() {
char c;
while((c=(char)getchar())!=EOF) {
putchar(translate(c));
}
return 0;
}
