Created
March 1, 2012 21:47
-
-
Save sivy/1953457 to your computer and use it in GitHub Desktop.
MD5 template filter for Django
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
from django import template | |
import hashlib | |
register = template.Library() | |
# | |
# {{ "some identifier"|md5 }} | |
# g87g98ht02497hg349ugh3409h34 | |
# | |
@register.filter(name='md5') | |
def md5_string(value): | |
return hashlib.md5(value).hexdigest() |
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
{% load myfilters %} | |
{% with "randstring"|add:user.email as email_key %} | |
user_hash: '{{ email_key|md5 }}' | |
{% endwith %} | |
outputs: | |
user_hash: 'snud763nwmf08nfn59qn3994nd...' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you