From c9a0c25a61131ad9d708c73fda2655f541a6640e Mon Sep 17 00:00:00 2001 From: liuhaojie Date: Fri, 7 Apr 2017 17:00:26 +0800 Subject: [PATCH 1/2] Add zip encode/decode. --- Default.sublime-commands | 8 ++++++++ Main.sublime-menu | 2 ++ xssencode.py | 22 ++++++++++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/Default.sublime-commands b/Default.sublime-commands index dab466b..5dae2d2 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -61,6 +61,14 @@ "caption": "XssEncode: StringToHex", "command": "string_to_hex" }, + { + "caption": "XssEncode: ZipDecode", + "command": "zip_decode" + }, + { + "caption": "XssEncode: ZipEncode", + "command": "zip_encode" + }, { "caption": "XssEncode: HexToString", "command": "hex_to_string" diff --git a/Main.sublime-menu b/Main.sublime-menu index 8b0f57c..b213732 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -24,6 +24,8 @@ {"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": "hex_to_string", "caption": "HexToString", "command": "hex_to_string"}, {"caption": "-"}, {"id": "unicode_encode", "caption": "UnicodeEncode", "command": "unicode_encode"}, diff --git a/xssencode.py b/xssencode.py index 400356d..4676c80 100644 --- a/xssencode.py +++ b/xssencode.py @@ -254,3 +254,25 @@ 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.") From 9bbb0583bd025fd7aca964e49e33d817d87af04f Mon Sep 17 00:00:00 2001 From: liuhaojie Date: Fri, 7 Apr 2017 17:05:43 +0800 Subject: [PATCH 2/2] Add powerful ROT13. : P --- Default.sublime-commands | 8 ++++++++ Main.sublime-menu | 2 ++ xssencode.py | 14 ++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/Default.sublime-commands b/Default.sublime-commands index 5dae2d2..928a496 100644 --- a/Default.sublime-commands +++ b/Default.sublime-commands @@ -69,6 +69,14 @@ "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" diff --git a/Main.sublime-menu b/Main.sublime-menu index b213732..d20230a 100644 --- a/Main.sublime-menu +++ b/Main.sublime-menu @@ -26,6 +26,8 @@ {"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"}, diff --git a/xssencode.py b/xssencode.py index 4676c80..037e2df 100644 --- a/xssencode.py +++ b/xssencode.py @@ -276,3 +276,17 @@ def convert(self, source_txt): 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