Created
November 13, 2016 22:53
-
-
Save IotaSpencer/09c00a85c4f22aca51f89aa642f8c7c5 to your computer and use it in GitHub Desktop.
supybot password encryption snippet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
def mkpasswd(self, irc, msg, args, password, digest): | |
"""<password> [digest] | |
Hashes the password into the chosen digest. / Uses sha256 if digest isn't given explicitly.""" | |
if digest == None: | |
m = hashlib.sha256() | |
m.update(b'%s' % password.encode('utf-8')) | |
m.digest | |
result = m.hexdigest() | |
irc.reply(result, private=True, notice=True) | |
if digest: | |
m = hashlib.new('%s' % digest) | |
m.update(b'%s' % password.encode('utf-8')) | |
m.digest | |
result = m.hexdigest() | |
irc.reply(result, private=True, notice=True) | |
mkpasswd = wrap(mkpasswd, ['something', optional('something')]) | |
def algorithms(self, irc, msg, args): | |
""" | |
Outputs the available algorithms""" | |
hashes = list(hashlib.algorithms_available) | |
result = " \xB7 ".join(hashes) | |
irc.reply(result) | |
algorithms = wrap(algorithms) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment