Skip to content

Instantly share code, notes, and snippets.

@timkofu
Last active December 15, 2015 22:50
Show Gist options
  • Save timkofu/5336295 to your computer and use it in GitHub Desktop.
Save timkofu/5336295 to your computer and use it in GitHub Desktop.
@never_cache
def caesar_decrypt(request):
def caesar_shift(crypt_text):
table = string.maketrans(
string.ascii_lowercase,
string.ascii_lowercase[13:]+string.ascii_lowercase[:13])
return string.translate(crypt_text.encode(errors="ignore").lower(), table)
if request.method == 'POST':
cipher_text = request.POST.get('cipher_text')
if cipher_text:
template_dict['clear_text'] = caesar_shift(cipher_text)
return render_to_response('caesar_decrypt.html', template_dict, context_instance=RequestContext(request))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment