Skip to main content

This is a Django application that provides methods to obfuscate/deobfuscate URLs

Project description

# url_ofbuscate
This is a Django application that provides methods to obfuscate/deobfuscate URLs.

## Quick start
Install using pip or easy_install

$ pip install url-obfuscate

$ easy_install url-obfuscate

Add "url_obfuscate" to your INSTALLED_APPS setting like this:

INSTALLED_APPS = (
...
'url_obfuscate',
)

## Usage
To obfuscate Django's URLs, modify the URL declaration in the urls.py file by replacing the regex definition with the funcion generate_url_pattern, as follows:

from url_obfuscate.helpers import generate_url_pattern
...

urlpatterns = patterns('views',
url(generate_url_pattern('/'), 'home', name='home'),
url(generate_url_pattern('obfuscated_link', params=['(?P<name>[^/]+)']), 'obfuscated_link', name='obfuscated_link'),
)

For the home URL, use / path. To include params in the URL, declare them in the desired order inside the params attribute. When obfuscating a URL with parameters, it is necessary to use the deobfuscate decorator to recover the original value of the parameter.

from url_obfuscate.decorators import deobfuscate
...

@deobfuscate
def obfuscated_link(request, name):
return render(request, 'obfuscate_result.html', { 'name': name })

When declaring URLs with parameters inside templates, use the obfuscate template tag, as follows:

{% load obfuscate %}
...
<p><a href="{% url 'obfuscated_link' 'Laura Manzur'|obfuscate %}">Obfuscated link: {% url 'obfuscated_link' 'Laura'|obfuscate %}</a></p>
...

If you need to obfuscate any value from inside a view, use the obfuscate function, as follows:

from url_obfuscate.helpers import obfuscate
...

def home(request):
links = list()
for i in range(10):
links.append(obfuscate('Name %d' % (i+1)))
return render(request, 'index.html', { 'links': links })

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

url-obfuscate-0.1.3.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

url-obfuscate-0.1.3.macosx-10.10-x86_64.exe (70.1 kB view details)

Uploaded Source

File details

Details for the file url-obfuscate-0.1.3.tar.gz.

File metadata

File hashes

Hashes for url-obfuscate-0.1.3.tar.gz
Algorithm Hash digest
SHA256 567b56f1b62c2149499fcc88a91067ef6ffa938ee38a9f43289d4fb7c6a70c88
MD5 e50a97386dd0627c268bf184025f26e9
BLAKE2b-256 60cc4daf953d79ac0b4554a1191a9cbbd561425d887afcad92a0e14b241d41ca

See more details on using hashes here.

File details

Details for the file url-obfuscate-0.1.3.macosx-10.10-x86_64.exe.

File metadata

File hashes

Hashes for url-obfuscate-0.1.3.macosx-10.10-x86_64.exe
Algorithm Hash digest
SHA256 be01b3a70cec8a3d355e20fba79ab0903bdfc5ba0c05f57c1d37f3cc50dbaf68
MD5 9564229bd6d4701ca81565ecd0adcd42
BLAKE2b-256 859999a20ccf89476c1ed9cab22498e0a4468036dc15a4bb5d98d85637d95949

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page