{"id":278,"date":"2012-11-13T22:42:08","date_gmt":"2012-11-14T03:42:08","guid":{"rendered":"http:\/\/dragonlordwarlock.com\/blog\/?p=278"},"modified":"2014-10-01T23:01:41","modified_gmt":"2014-10-02T04:01:41","slug":"rot13-c","status":"publish","type":"post","link":"https:\/\/dragonlordwarlock.com\/blog\/?p=278","title":{"rendered":"ROT13 C++"},"content":{"rendered":"<p>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 <a title=\"Rot13 Download\" href=\"http:\/\/dragonlordwarlock.com\/release\/rot13.7z\">here<\/a>.<\/p>\n<blockquote>\n<pre class=\"theme:obsidian font-size:14 toolbar:2 nums:false nums-toggle:false lang:c++ decode:true \">#include &lt;cstring&gt;\r\n#include &lt;cstdio&gt;\r\n#include &lt;cctype&gt;\r\n\r\nusing namespace std;\r\n\r\nchar translate(char c)\r\n{\r\n    int cflag = 0;\r\n    char oc = c;\r\n    char alphabet[] = \"abcdefghijklmnopqrstuvwxyz\";\r\n    int alphalen = strlen(alphabet);\r\n    if(isalpha(c)) {\r\n        if(isupper(c)) {\r\n            cflag = 1;\r\n            c = tolower(c);\r\n        }\r\n        for(int i=0;i&lt;alphalen; ++i) {\r\n            if(c==alphabet[i]) {\r\n                oc = alphabet[(i+13)%alphalen];\r\n            }\r\n        }\r\n        if(cflag==1) {\r\n            oc = toupper(oc);\r\n        }\r\n    }\r\n    return oc;\r\n}\r\n\r\nint main() {\r\n    char c;\r\n    while((c=(char)getchar())!=EOF) {\r\n        putchar(translate(c));\r\n    }\r\n    return 0;\r\n}\r\n<\/pre>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>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 &lt;cstring&gt; #include &lt;cstdio&gt; #include &lt;cctype&gt; using namespace std; char translate(char &#8230; <a href=\"https:\/\/dragonlordwarlock.com\/blog\/?p=278\" class=\"more-link\">Read More<span class=\"screen-reader-text\"> &#8220;ROT13 C++&#8221;<\/span> &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[29,32],"tags":[],"class_list":["post-278","post","type-post","status-publish","format-standard","hentry","category-c","category-programming"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/278","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=278"}],"version-history":[{"count":9,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions"}],"predecessor-version":[{"id":525,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/278\/revisions\/525"}],"wp:attachment":[{"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=278"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=278"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dragonlordwarlock.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=278"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}