<s> from Crypto . Cipher import AES <EOL> from django . conf import settings <EOL> from django . http import HttpResponse <EOL> from django . core . urlresolvers import reverse <EOL> from django . shortcuts import render <EOL> from . utils import get_client_key , get_userscript_code , get_decode_key <EOL> from . forms import DecodeForm <EOL> class TestException ( Exception ) : <EOL> pass <EOL> def userscript ( request ) : <EOL> response = HttpResponse ( <EOL> get_userscript_code ( request ) , <EOL> mimetype = '<STR_LIT>' <EOL> ) <EOL> response [ '<STR_LIT>' ] = '<STR_LIT>' % get_client_key ( ) <EOL> return response <EOL> def test ( _request ) : <EOL> raise TestException ( "<STR_LIT>" ) <EOL> def setup ( request ) : <EOL> return render ( request , "<STR_LIT>" , { <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : reverse ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : '<STR_LIT>' not in settings . MIDDLEWARE_CLASSES , <EOL> '<STR_LIT>' : settings . DEBUG , <EOL> } ) <EOL> def decode ( request ) : <EOL> if request . method == "<STR_LIT:POST>" : <EOL> form = DecodeForm ( request . POST ) <EOL> if form . is_valid ( ) : <EOL> message = form . cleaned_data [ '<STR_LIT:message>' ] <EOL> optional_decode_key = form . cleaned_data [ '<STR_LIT>' ] <EOL> decode_key = optional_decode_key or get_decode_key ( ) <EOL> return HttpResponse ( <EOL> AES . new ( <EOL> decode_key , <EOL> AES . MODE_CBC , <EOL> message [ : <NUM_LIT:16> ] , <EOL> ) . decrypt ( <EOL> message [ <NUM_LIT:16> : ] <EOL> ) <EOL> ) <EOL> else : <EOL> form = DecodeForm ( ) <EOL> return render ( request , "<STR_LIT>" , { <EOL> "<STR_LIT>" : form <EOL> } ) </s>
