Snippet List
Update to https://djangosnippets.org/snippets/1907/ to be a bit more flexible, and code cleaned up a tiny bit.
To use, add this snippet as a file in a templatetags folder in an app or in a project. Then include and call the tag with
{% obfuscate_email 'email' %}
or
{% obfuscate_email 'email' 'link_text' %}
if 'link_text' is provided, it will be used as the text in the body of the <a> tag. If not, then the email will be used.
This is a Django Template Tag to protect the E-mail address you publish on your website against bots or spiders that index or harvest E-mail. It uses a substitution cipher with a different key for every page load.
It basically produce a equivalent Javascript code for an email address. This code when executed by browser make it mailto link.
**Usage**
`{% encrypt_email user.email %}`
**More Info **
[Template Tag to protect the E-mail address](http://www.nitinh.com/2010/02/django-template-tag-to-protect-the-e-mail-address/)
- template
- django
- javascript
- email
- template-tag
- obfuscate
- bots
- spider
Template tag to obfuscate emails and other spam sensitive information.
Usage
obfuscate '[email protected]' 'Link display' 'Link title'
obfuscate '[email protected]' 'Link display'
obfuscate 'phone number'
Renders complex xhmtl compliant javascript.
May need caching as it renders a new code every time.
- template
- tag
- javascript
- obfuscate
This script can be useful if you want to obfuscate your django project sources.
I use the [pyobfuscate](http://freshmeat.net/projects/pyobfuscate/) tool, a little bit patched, the patch you can get [here](http://farid.adigamov.com/files/pyobfuscate.patch). The patch switchs off the classes and methods obfuscation as they could be imported from other files.
The **pyobfuscate** util can obfuscate only one file at once. This script can obfuscate all .py files from the specified path (src_dir), at the end of the obfuscation it compiles them using **compileall** module.
Set the **src_dir** and the **dst_dir** variables.
Note: remove original **settings.py** and **urls.py** from the **src_dir** cause **pyobfuscate** util raises an error trying to encode them.
The decorators are not handled correctly by pyobfuscate tool. I'm using django for about year and i didn't use the decorators except the '@transaction' decorators.
I replace them from the sources at the beginning of the obfuscation and put them at their places in encoded file.
In case of using other decorators you should make some changes in code ( line # 64 ).
- obfuscate
- sources
- hide
- obfuscator
5 snippets posted so far.