Skip to content

Instantly share code, notes, and snippets.

@IotaSpencer
Created November 13, 2016 22:53
Show Gist options
  • Save IotaSpencer/09c00a85c4f22aca51f89aa642f8c7c5 to your computer and use it in GitHub Desktop.
Save IotaSpencer/09c00a85c4f22aca51f89aa642f8c7c5 to your computer and use it in GitHub Desktop.
supybot password encryption snippet
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