Skip to content

Commit

Permalink
Merge pull request #2 from tr33oph 👍
Browse files Browse the repository at this point in the history
Add zip and rot13 encode/decode.
  • Loading branch information
Medicean authored Apr 12, 2017
2 parents f2778a6 + 9bbb058 commit e470136
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,22 @@
"caption": "XssEncode: StringToHex",
"command": "string_to_hex"
},
{
"caption": "XssEncode: ZipDecode",
"command": "zip_decode"
},
{
"caption": "XssEncode: ZipEncode",
"command": "zip_encode"
},
{
"caption": "XssEncode: Rot13Decode",
"command": "rot13_decode"
},
{
"caption": "XssEncode: Rot13Encode",
"command": "rot13_encode"
},
{
"caption": "XssEncode: HexToString",
"command": "hex_to_string"
Expand Down
4 changes: 4 additions & 0 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
{"id": "php_unchr", "caption": "PHPUnchr", "command": "php_unchr"},
{"caption": "-"},
{"id": "string_to_hex", "caption": "StringToHex", "command": "string_to_hex"},
{"id": "unzip_decode", "caption": "ZipDecode", "command": "zip_decode"},
{"id": "unzip_encode", "caption": "ZipEncode", "command": "zip_encode"},
{"id": "rot13_decode", "caption": "Rot13Decode", "command": "rot13_decode"},
{"id": "rot13_encode", "caption": "Rot13Encode", "command": "rot13_encode"},
{"id": "hex_to_string", "caption": "HexToString", "command": "hex_to_string"},
{"caption": "-"},
{"id": "unicode_encode", "caption": "UnicodeEncode", "command": "unicode_encode"},
Expand Down
36 changes: 36 additions & 0 deletions xssencode.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,39 @@ def convert(self, source_txt):
return text
except:
sublime.error_message("Can not convert to UnicodeEncode")

class ZipDecodeCommand(XssEncodeCommand):

def convert(self, source_txt):
text = ""
try:
import zlib, codecs
text = zlib.decompress(codecs.escape_decode(source_txt)[0]).decode()
return text
except:
sublime.error_message("Unzip failed.")

class ZipEncodeCommand(XssEncodeCommand):

def convert(self, source_txt):
text = ""
try:
import zlib, codecs
text = zlib.compress(source_txt.encode())
return codecs.escape_encode(text)[0].decode()
except:
sublime.error_message("Zip failed.")

class Rot13EncodeCommand(XssEncodeCommand):

def convert(self, source_txt):
text = ""
try:
import codecs
text = codecs.encode(source_txt, "rot-13")
return text
except:
sublime.error_message("Rot13 convert failed.")

class Rot13DecodeCommand(Rot13EncodeCommand):
pass

0 comments on commit e470136

Please sign in to comment.