[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]

/prog/ - Programming

Programming board

Catalog

Name
Email
Subject
Comment *
File
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Embed
(replaces files and can be used instead)
Options
Password (For file and post deletion.)

Allowed file types:jpg, jpeg, gif, png, webm, mp4, pdf
Max filesize is 8 MB.
Max image dimensions are 10000 x 10000.
You may upload 1 per post.


File: 1458269312215.gif (122.01 KB, 350x435, 70:87, watson and holmes discussi….gif)

4b97cb No.4025

Rot13 thread!


key = 13
U = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
L = 'abcdefghijklmnopqrstuvwxyz'
rot13 = str.maketrans(U + L, U[key:] + U[:key] + L[key:] + L[:key])

print('rot13 is cool!'.translate(rot13))

00ecae No.4027

type 256 ohssre: gnoyr
: genafyngr ( p -- p' ) gnoyr + p@ ;

mnexre renfr
: genafyngr! ( p p' -- ) fjnc gnoyr + p! ;
: vqragvgl ( n-gnoyr -- ) 256 0 qb v qhc genafyngr! ybbc ;
: ebg13-gnoyr ( n-gnoyr -- )
[ pune z ] yvgreny [pune] a qb v qhc 13 - genafyngr! ybbc
[ pune Z ] yvgreny [pune] A qb v qhc 13 - genafyngr! ybbc
[ pune m ] yvgreny [pune] n qb v qhc 13 + genafyngr! ybbc
[ pune M ] yvgreny [pune] N qb v qhc 13 + genafyngr! ybbc ;

vqragvgl
ebg13-gnoyr
renfr

: ebg13 ( 'fgevat' -- )
obhaqf qb v p@ genafyngr v p! ybbc ;

fbhepr 2qhc ebg13 type

A pretend-generic solution. You could make any kind of ASCII translation with that table, or write a "maketrans" that maps one string's characters to another, or a "rotate" that maps characters to a rotation of themselves.

But since you only want rot13 it's a lot of wasted code. Not Forthy. Which is why it's erased from the dictionary after use. That way, if an executable is built, it'll just have the translation table as set up for rot13, and none of the code that set it up.

The last line prints itself out, rot13'd. 'glcr' is the rot13 of 'type', the Forth word that prints a string. Yes, the source code is modified so that 'glcr' becomes 'type' before Forth looks at it to run it.

Source is copyright protected and is encrypted. Breaking encryption is a violation of the DMCA and FBI FBI FBI fucko


07a276 No.4039

File: 1458537062815.webm (3.27 MB, 320x240, 4:3, wow.webm)

>>4025

>>4027

read a book, rot13 is trivial.


#include <bits/stdc++.h>
using namespace std;
int main() {
string l;
while(getline(cin, l)) {
for(int i = 0; i < l.size(); ++i) {
if(isalpha(l[i])) {
cout << (char)(((tolower(l[i]) - 'a') + 13)%26 + (islower(l[i]) ? 'a' : 'A'));
} else {
cout << l[i];
}
}
cout << '\n';
}
return 0;
}


75440c No.4041

>>4039

Ugly code.


13ec00 No.4044

>rot13

>an accomplishment


int rot13(char **original) {
for(int i = 0; i < strlen(original); i++) {
if(*original[i] >= 65 && *original[i] <= 90) {
*original[i] = (*original[i] - 52) % 26 + 65
} else if(*original[i] >= 90 && *original[i] <= 122) {
*original[i] = (*original[i] - 77) % 26 + 90
}
}
return 0
}


75440c No.4047

>>4044

It's just a bit of fun.


var rot13 = {
alpha: "AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz",
key: 13,

translateChar: function(ch) {
return !ch.match(/[A-Z]/i) ? ch :
this.alpha[(this.alpha.indexOf(ch) + this.key * 2) % this.alpha.length];
},

translate: function(text) {
var result = [];
for (var i in text) {
result.push(this.translateChar(text[i]));
}
return result.join("");
}
};

alert(rot13.translate("Rot13 is cool!"));




[Return][Go to top][Catalog][Post a Reply]
Delete Post [ ]
[]
[ home / board list / faq / random / create / bans / search / manage / irc ] [ ]