Skip to content

Commit

Permalink
New improved random key
Browse files Browse the repository at this point in the history
Improved key string.
Typo fix + added installation guide in readme
  • Loading branch information
iamfredric committed Apr 26, 2014
1 parent eba8274 commit 7da8bd0
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Wpkeygen.pyc
*.pyc
27 changes: 17 additions & 10 deletions Wpkeygen.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import sublime, sublime_plugin, hashlib, random
import sublime, sublime_plugin, random, string, os

class WpkeygenCommand(sublime_plugin.TextCommand):

def run(self, edit):
ListReplacements = []
Hasher = hashlib.sha1()
def run(self, edit):
ListReplacements = []

RegionsResult = self.view.find_all(r"(define\(')([A-Z_]+)(_)(KEY|SALT)(',)(.*?)(\);)", sublime.IGNORECASE, "\\1\\2\\3\\4\\5'THISBITSHOLDBEREPLACED'\\7", ListReplacements)

for i, thisregion in reversed(list(enumerate(RegionsResult))):
newsalt = ListReplacements[i].replace('THISBITSHOLDBEREPLACED', self.rsv())
self.view.replace(edit, thisregion, newsalt)

def rsv(self):
length = 64
chars = string.ascii_letters + string.digits + '!@#$%^&*()`|_}-&><#{=.][;:+/'
random.seed = (os.urandom(1024))
return ''.join(random.choice(chars) for i in range(length))



RegionsResult = self.view.find_all(r"(define\(')([A-Z_]+)(_)(KEY|SALT)(',)(.*?)(\);)", sublime.IGNORECASE, "\\1\\2\\3\\4\\5'THISBITSHOLDBEREPLACED'\\7", ListReplacements)

for i, thisregion in reversed(list(enumerate(RegionsResult))):
hashstring = "%032x" % random.getrandbits(128)
Hasher.update(hashstring.encode('utf-8'))
newsalt = ListReplacements[i].replace('THISBITSHOLDBEREPLACED', Hasher.hexdigest())
self.view.replace(edit, thisregion, newsalt)
4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Wordpress keygen Sublime Text plugin
============================
Generate wordpress keys and salts from Sublime text 2 and 3.
Generate wordpress keys and salts for Sublime text 2 and 3.

How to use
----------
Expand All @@ -13,4 +13,4 @@ Mac, Linux and Windows: ctrl+alt+k

Installation
------------
At the moment only by download at github
At the moment only by download at github, simply drop the package in your sublime text package folder

0 comments on commit 7da8bd0

Please sign in to comment.