StruckOFF

bydlo_script

Jul 24th, 2014
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. from django.template import RequestContext
  2. from django.http import HttpResponseRedirect, HttpResponse
  3. import json
  4. from django.shortcuts import *
  5. import hashlib
  6.  
  7. def ld45_tpl(request):
  8.     return render_to_response("web/ld45.html",context_instance=RequestContext(request))
  9.  
  10. def ld45(request):
  11.     for_return ={
  12.                 "info_function":"ld45",
  13.                 "result":"Not POST ?",
  14.                 }
  15.    
  16.     if request.method == "POST":
  17.         def to_hash(line,ch):
  18.             line = line.encode('utf-8')
  19.             types = {
  20.                         "md5":hashlib.md5,
  21.                         "sha512":hashlib.sha512,
  22.                         "sha224":hashlib.sha224,
  23.                         "sha1":hashlib.sha1
  24.                     }
  25.  
  26.             m = types[ch]()
  27.             m.update(line)
  28.             return m.hexdigest()
  29.  
  30.         for_return["result"]=to_hash(request.POST["srt_to_md5"],request.POST["ch"])
  31.  
  32.     return HttpResponse(json.dumps(for_return), mimetype='application/json')
Advertisement
Add Comment
Please, Sign In to add comment