snipt/utils/templatetags/intercom.py

17 lines
396 B
Python
Raw Normal View History

2014-10-30 09:17:47 -07:00
from django.conf import settings
2014-08-18 09:01:33 -07:00
from django import template
2015-07-24 18:28:31 -07:00
import hmac
import hashlib
import os
2014-08-18 09:01:33 -07:00
register = template.Library()
2015-07-24 18:28:31 -07:00
2014-08-18 09:01:33 -07:00
@register.filter
def intercom_sha_256(user_id):
2015-07-24 18:28:31 -07:00
return hmac.new(os.environ.get('INTERCOM_SECRET_KEY',
settings.INTERCOM_SECRET_KEY),
str(user_id),
digestmod=hashlib.sha256).hexdigest()