Skip to content

Commit

Permalink
Add Sha1、 Sha256、 Sha512、Sha224、Sha384
Browse files Browse the repository at this point in the history
  • Loading branch information
Medicean committed May 1, 2017
1 parent 0203b38 commit fee5494
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### v1.0.2 (2017/05/01)

* Add Sha1、 Sha256、 Sha512、Sha224、Sha384

```
test => a94a8fe5ccb19ba61c4c0873d391e987982fbbd3
test => 9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08
```

### v1.0.1 (2017/04/12)

* Add `ZipEncode` and `ZipDecode`
Expand Down
20 changes: 20 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,26 @@
"caption": "XssEncode: MD5_Encode",
"command": "md5_encode"
},
{
"caption": "XssEncode: SHA1_Encode",
"command": "sha1_encode"
},
{
"caption": "XssEncode: SHA256_Encode",
"command": "sha256_encode"
},
{
"caption": "XssEncode: SHA512_Encode",
"command": "sha512_encode"
},
{
"caption": "XssEncode: SHA224_Encode",
"command": "sha224_encode"
},
{
"caption": "XssEncode: SHA384_Encode",
"command": "sha384_encode"
},
{
"caption": "XssEncode: StringFromCharCode",
"command": "string_from_char_code"
Expand Down
7 changes: 6 additions & 1 deletion Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@
{"id": "unicode_encode", "caption": "UnicodeEncode", "command": "unicode_encode"},
{"id": "unicode_decode", "caption": "UnicodeDecode", "command": "unicode_decode"},
{"caption": "-"},
{"id": "md5_encode", "caption": "MD5_Encode", "command": "md5_encode"}
{"id": "md5_encode", "caption": "MD5_Encode", "command": "md5_encode"},
{"id": "sha1_encode", "caption": "SHA1_Encode", "command": "sha1_encode"},
{"id": "sha256_encode", "caption": "SHA256_Encode", "command": "sha256_encode"},
{"id": "sha512_encode", "caption": "SHA512_Encode", "command": "sha512_encode"},
{"id": "sha224_encode", "caption": "SHA224_Encode", "command": "sha224_encode"},
{"id": "sha384_encode", "caption": "SHA384_Encode", "command": "sha384_encode"}
]
}]
}]
54 changes: 52 additions & 2 deletions xssencode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import sublime
import sublime_plugin
__VERSION__ = '1.0.1'
__VERSION__ = '1.0.2'


class XssEncodeCommand(sublime_plugin.TextCommand):
Expand Down Expand Up @@ -79,6 +79,48 @@ def convert(self, source_txt):
return hashlib.md5(source_txt.encode("utf-8")).hexdigest()


class Sha1EncodeCommand(XssEncodeCommand):
def convert(self, source_txt):
try:
import hashlib
except:
return source_txt
return hashlib.sha1(source_txt.encode("utf-8")).hexdigest()


class Sha256EncodeCommand(XssEncodeCommand):
def convert(self, source_txt):
try:
import hashlib
except:
return source_txt
return hashlib.sha256(source_txt.encode("utf-8")).hexdigest()

class Sha512EncodeCommand(XssEncodeCommand):
def convert(self, source_txt):
try:
import hashlib
except:
return source_txt
return hashlib.sha512(source_txt.encode("utf-8")).hexdigest()

class Sha224EncodeCommand(XssEncodeCommand):
def convert(self, source_txt):
try:
import hashlib
except:
return source_txt
return hashlib.sha224(source_txt.encode("utf-8")).hexdigest()

class Sha384EncodeCommand(XssEncodeCommand):
def convert(self, source_txt):
try:
import hashlib
except:
return source_txt
return hashlib.sha384(source_txt.encode("utf-8")).hexdigest()


class Html10EncodeCommand(XssEncodeCommand):
def convert(self, source_txt):
text = ""
Expand Down Expand Up @@ -284,10 +326,18 @@ def convert(self, source_txt):
text = ""
try:
import codecs
text = codecs.encode(source_txt, "rot-13")
text = codecs.encode(source_txt, "rot-13")
return text
except:
sublime.error_message("Rot13 convert failed.")

class Rot13DecodeCommand(Rot13EncodeCommand):
pass

class TestCommand(XssEncodeCommand, sublime_plugin.WindowCommand):

def convert(self, source_txt):
self.view.window().show_input_panel('do:', 'No', self.on_done, None, None)

def on_done(self, m):
sublime.status_message(m)

0 comments on commit fee5494

Please sign in to comment.