Skip to content
DragonlordWarlock.com

DragonlordWarlock.com

Home of the Dragonlord Warlock/Norin Nightfire

  • Home
  • About Me
  • Poetry
  • Photos
  • Programming
  • Wallpaper
  • Norin Nightfire
  • Privacy Policy
  • Home
  • ROT13 C++

ROT13 C++

Posted on 2012-11-132014-10-01 By Administrator
c++, programming

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;
}

Post navigation

❮ Previous Post: Old Pin-up photoshop sketch effect
Next Post: Haiku ❯

You may also like

c++
Linkable Object C++ Hello World
2019-06-19
Chlo
Chloe
2016-01-03
javascript
Javascript
2012-11-18
downloading
Batch downloading with REXX and WGET
2007-08-15

Archives

Categories

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Advert

  • Facebook

Copyright © 2026 DragonlordWarlock.com.

Theme: Oceanly News Dark by ScriptsTown