Skip to content

Commit

Permalink
Merge pull request #28 from ildarkhasanshin/master
Browse files Browse the repository at this point in the history
add generate password with spec symbols
  • Loading branch information
akalongman authored Oct 9, 2016
2 parents 0d8a3c7 + c30703f commit 1437977
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.pyc
*.todo
7 changes: 7 additions & 0 deletions Context.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
{ "command": "generate_password", "caption": "Generate Password (32 char)", "args": {"length": "32"} },
{ "command": "generate_password", "caption": "Generate Password (40 char)", "args": {"length": "40"} },
{ "command": "generate_password", "caption": "Generate Password (64 char)", "args": {"length": "64"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (6 char)", "args": {"length": "6"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (8 char)", "args": {"length": "8"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (12 char)", "args": {"length": "12"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (16 char)", "args": {"length": "16"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (32 char)", "args": {"length": "32"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (40 char)", "args": {"length": "40"} },
{ "command": "generate_password_spec_symbols", "caption": "Generate Password with spec symbols (64 char)", "args": {"length": "64"} },
{ "caption": "-" },
{ "command": "decode_heidi_sql", "caption": "Decode HeidiSQL password"},
{ "caption": "-" },
Expand Down
35 changes: 35 additions & 0 deletions Default.sublime-commands
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,41 @@
"command": "generate_password",
"args": {"length": "64"}
},
{
"caption": "String Utilities: Insert Password (6 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "6"}
},
{
"caption": "String Utilities: Insert Password (8 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "8"}
},
{
"caption": "String Utilities: Insert Password (12 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "12"}
},
{
"caption": "String Utilities: Insert Password (16 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "16"}
},
{
"caption": "String Utilities: Insert Password (32 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "32"}
},
{
"caption": "String Utilities: Insert Password (40 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "40"}
},
{
"caption": "String Utilities: Insert Password (64 char)",
"command": "generate_password_spec_symbols",
"args": {"length": "64"}
},
{
"caption": "String Utilities: Decode HeidiSQL password",
"command": "decode_heidi_sql"
Expand Down
9 changes: 8 additions & 1 deletion stringutilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,13 +385,20 @@ def run(self, edit, length=16):
length = int(length)
self.view.insert(edit, self.view.sel()[0].begin(), ''.join(sample(self.chars, length)))

class GeneratePasswordSpecSymbolsCommand(sublime_plugin.TextCommand):
chars = "0123456789abcdefghijkmnpqrstuvwxyzABCDEFGHKMNPQRSTUVWXYZ%*)?@#$~"

def run(self, edit, length=16):
length = int(length)
self.view.insert(edit, self.view.sel()[0].begin(), ''.join(sample(self.chars, length)))

class DecodeHeidiSqlCommand(sublime_plugin.TextCommand):
# Requires .strip('\x00') on output otherwise sublimetext adds a 'NUL' control chracter
def run(self, edit):
for region in self.view.sel():
if not region.empty():
text = self.view.substr(region)
if text[0].isdigit(): text = self.decodeHeidi(text)
if text[0].isdigit(): text = self.decodeHeidi(text)
self.view.replace(edit, region, text)

def decodeHeidi(self, hex_in):
Expand Down

0 comments on commit 1437977

Please sign in to comment.