OLW: #Javascript ROT13

Here is a Javascript #one-liner to perform ROT13 on a string variable s.

s.replace(/[a-zA-Z]/g,function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26)});

Use it to very lightly obfuscate anything you wouldn’t mind being discovered. For example, if you ran a forum and wanted to hide all spoiler text from search results, you could store it in ROT13 form, and then decode it when a user clicks the “show spoiler” button.

“I’d call him a sadistic, hippophilic necrophile, but that would be beating a dead horse.” – Woody Allen


One thought on “OLW: #Javascript ROT13

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s