grim/hgwebplus

894b0edb6871
Parents
Children be21790699f8
initial commit just the md5 and sha256 filters
  • +26 -0
    hgkeeper.py
  • --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/hgkeeper.py Sat Mar 21 17:36:51 2020 -0500
    @@ -0,0 +1,26 @@
    +# vi:et:ts=4 sw=4 sts=4
    +
    +import hashlib
    +
    +from mercurial import registrar
    +
    +filters = {}
    +templatefilter = registrar.templatefilter(filters)
    +
    +def hexdigest(algo, text):
    + h = hashlib.new(algo)
    + h.update(text)
    +
    + return h.hexdigest()
    +
    +
    +@templatefilter(b'md5', intype=bytes)
    +def md5(text):
    + return hexdigest('md5', text)
    +
    +
    +@templatefilter(b'sha256', intype=bytes)
    +def sha256(text):
    + return hexdigest('sha256', text)
    +
    +