@@ -0,0 +1,1825 @@
+# -*- coding: utf-8 -*-%0A# mkpasswd.py%0A%0A# Author: Ken Spencer%0A# Author Nick: Iota%0A# Version: 0.0.1%0A# License: MPL%0A%0Afrom pylinkirc import utils%0Afrom pylinkirc.log import log%0A%0Aimport re%0Aimport hashlib%0A    %0A%0Adef mkpasswd(irc, source, args):%0A    %22%22%22%3Cpassword%3E %5Bdigest%5D%0A    Hashes a given password with the given digest, when 'digest' isn't given, defaults to sha256%22%22%22%0A    digest = %22%22%0A    try:%0A        password = args%5B0%5D%0A        try:%0A            digest = args%5B1%5D%0A        except IndexError:%0A            digest = %22sha256%22%0A        # DRY'ing%0A        digests = hashlib.algorithms_available %0A        if digest:%0A            if digest in digests:%0A                d = hashlib.new(%22%25s%22 %25 digest)%0A                d.update(b'%25s' %25 password.encode('utf-8'))%0A                irc.reply(d.hexdigest(), private=True)%0A            else:%0A                irc.error(%22hash algorithm '%25s' unavailable, see 'algorithms'%22 %25 digest, private=True)%0A        else:%0A            d = hashlib.new(%22sha256%22)%0A            d.update(b'%25s' %25 password.encode('utf-8'))%0A            irc.reply(d.hexdigest(), private=True)%0A    except IndexError:%0A        irc.error(%22Not enough arguments. Needs 1-2: password, digest (optional).%22, private=True)%0A%0A%0Adef algorithms(irc, source, args):%0A    %22%22%22algorithms %5Bquery%5D%0A    When given '.' gives all available algorithms, or will filter the available when given a starting few characters.%22%22%22%0A    try:%0A        digest = args%5B0%5D%0A        pattern = re.compile(r%22%25s.*%22 %25 digest, re.I)%0A        avail_digests = filter(pattern.search, list(hashlib.algorithms_available))%0A        avail_digests = %22 %5CxB7 %22.join(avail_digests)%0A        irc.reply(avail_digests, private=True)%0A    except IndexError:%0A        irc.error(%22Not enough arguments. Needs 1: query.%22, private=True)%0A%0A    %0Autils.add_cmd(algorithms, %22algorithms%22)%0Autils.add_cmd(mkpasswd, %22mkpasswd%22)%0A

add mkpasswd to contrib modules