Home Download Buy Blog Forum Support

Encrypt Line / Selection (ROT 13)

Encrypt Line / Selection (ROT 13)

Postby ninjaroll on Thu May 24, 2012 8:33 pm

Recent convert from TextMate and gotta say that I'm really liking ST2. One feature that I do miss on occasion is encrypting selected text. This comes in handy when displaying email addresses on the page in a way where the email address is obfuscated from spambots. Directly from Textmate is this command:

Code: Select all
#!/usr/bin/env ruby

def e_js(str)
  str.gsub(/(?=[\\"])/, '\\').gsub(/\n/, '\n').gsub(/[@.\/]/) { |ch| sprintf('\\%03o', ch[0]) }

def rot_13(str)
  str.tr('A-Za-z', 'N-ZA-Mn-za-m')

print %{<script type="text/javascript">document.write(
"#{e_js(rot_13(STDIN.read))}".replace(/[a-zA-Z]/g, function(c){return String.fromCharCode((c<="Z"?90:122)>=(c=c.charCodeAt(0)+13)?c:c-26);}));

I also found this on Github, although it looks a bit different:

Can this be somehow implemented into ST2??

Posts: 31
Joined: Tue Jan 03, 2012 7:10 pm

Re: Encrypt Line / Selection (ROT 13)

Postby atomi on Fri May 25, 2012 2:42 am

You can make a quick plugin for this.

Here is the api reference http://www.sublimetext.com/docs/2/api_reference.html

Not sure how well this works but it's the first thing that popped up in Google:
http://stackoverflow.com/questions/3269 ... 3-function
Posts: 345
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Re: Encrypt Line / Selection (ROT 13)

Postby sublimator on Fri May 25, 2012 3:54 am

This used to be built in to Sublime 1 - or maybe it was just an example plugin in the docs

In any case, rot13 encoding is built into Sublime.

Code: Select all
>>> 'rot13'.encode('rot13')

It is better to remain silent and be thought a fool, than to speak out and remove all doubt
Posts: 645
Joined: Thu Mar 20, 2008 5:41 am

Return to Technical Support

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests