Skip to content

Commit

Permalink
Cleaned up readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomatohater committed Aug 12, 2011
1 parent 62f2767 commit 4eb8694
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 12 deletions.
18 changes: 9 additions & 9 deletions README.rst
@@ -1,31 +1,31 @@
django-unfriendly
========================

django-unfriendly is a Django app that obfuscates URLs and allows your application to natively execute the original URL's view.
django-unfriendly is a Django app that obfuscates urls and allows your application to natively execute the original url's view.

There is lots of talk about SEO friendly URLs. The trend is towards more and more readable human information in your URLs and Django makes it easy to create URLs like::
There is lots of talk about SEO friendly urls. The trend is towards more and more readable human information in your urls and Django makes it easy to create urls like::

http://yoursite.com/music/black-sabbath-is-awesome/

But sometimes URLs can give too much away. This is where django-unfriendly comes in.
But sometimes urls can give too much away. This is where django-unfriendly comes in.

django-unfriendly provides a template filter that obfuscates URLs in your templates, and a URL handler that deobfuscates and executes the original view (no redirection).
django-unfriendly provides a template filter that obfuscates urls in your templates, and a url handler that deobfuscates and executes the original view (no redirection).


Why?
****

Perhaps you have a Django application with URLs like the one above and you don't want anyone tampering with your URLs or guessing other possibilities::
Perhaps you have a Django application with urls like the one above and you don't want anyone tampering with your urls or guessing other possibilities::

http://yoursite.com/music/melvins-are-awesome/

You can obfuscation the URL which might look like::
You can obfuscation the url which might look like::

http://yoursite.com/u/E5v4uxuNSA8I2is33c6V8lqFTcdv_IxPLDGG/

Tampering with the obfuscated URL should return a ``404 - Page not found`` error.
Tampering with the obfuscated url should return a ``404 - Page not found`` error.

Obfuscated URLs are idempotent and may be safely cached.
Obfuscated urls are idempotent and may be safely cached.


Installation
Expand Down Expand Up @@ -56,7 +56,7 @@ Load this tag library into any templates where you want to use django-unfriendly

{% load unfriendly_tags %}

Then apply the obfuscate filter to any URL you'd like to hide::
Then apply the obfuscate filter to any url you'd like to hide::

<a href="{{ "/music/black-sabbath-is-awesome/"|obfuscate }}">Sabbath awesome</a>

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -10,7 +10,7 @@ def read(fname):
setup(
name = "django-unfriendly",
version = unfriendly.__version__,
description = 'The unfriendliest urls in town.',
description = 'The unfriendliest urls in town! Django app that obfuscates urls and allows your application to natively execute the original view.',
long_description = README,
url = 'http://github.com/tomatohater/django-unfriendly',
author = 'Drew Engelson',
Expand Down
4 changes: 2 additions & 2 deletions unfriendly/tests/__init__.py
Expand Up @@ -15,9 +15,9 @@ class UnfriendlyTests(TestCase):
def setUp(self):
self.juice = 'Lorem ipsum dolor sit amet'

def test_obfuscator(self):
def test_encryption(self):
"""
Test the Obfuscator.
Test the encryption.
"""
original = self.juice

Expand Down
4 changes: 4 additions & 0 deletions unfriendly/utils.py
Expand Up @@ -3,15 +3,18 @@
import struct
from Crypto.Cipher import AES


class CheckSumError(Exception):
pass


def _lazysecret(secret, blocksize=32, padding='}'):
"""Pads secret if not legal AES block size (16, 24, 32)"""
if not len(secret) in (16, 24, 32):
return secret + (blocksize - len(secret)) * padding
return secret


def encrypt(plaintext, secret, checksum=True, lazy=True):
"""Encrypts plaintext with secret
plaintext - content to encrypt
Expand All @@ -30,6 +33,7 @@ def encrypt(plaintext, secret, checksum=True, lazy=True):

return base64.urlsafe_b64encode(encobj.encrypt(plaintext)).replace('=', '')


def decrypt(ciphertext, secret, checksum=True, lazy=True):
"""Decrypts ciphertext with secret
ciphertext - encrypted content to decrypt
Expand Down

0 comments on commit 4eb8694

Please sign in to comment.