Пример #1
0
	def do_GET(self):
		try:
			print "GET received",self.path
			#if self.path.endswith(".html"):
			self.send_response(200)
			self.send_header('Content-type','text/html')
			self.end_headers()
			self.wfile.write(default_page('encrypt','This is the input','','This is the output','',''))
			return
		except:
			self.send_error(404,'Where the hell you \'goin?')
Пример #2
0
	def do_POST(self):
		global rootnode
		try:
			print "POST received"
			form = cgi.FieldStorage(fp=self.rfile,
						headers=self.headers,
						environ={'REQUEST_METHOD':'POST',
							'CONTENT_TYPE':self.headers['Content-type']})
			action = 'encrypt'
			hashstring = ''
			inputString = ''
			secretString = ''
			tohashString = ''
			outputString = ''
			if "secret" in form:
				inputString = form['input'].value
				secretString = form['secret'].value
				inputString = cgi.escape(inputString,True)
				secretString = cgi.escape(secretString,True)
				if form['type'].value == 'encrypt':
					outputString = encrypt("AES",secretString,inputString)
					#keep the default behavior/action
				elif form['type'].value == 'decrypt':
					outputString = decrypt(secretString,inputString)
					#remain on decrypt
					action = 'decrypt'
			if "string" in form:
				tohashString = form['string'].value
				tohashString = cgi.escape(tohashString,True)
				hashstring = makehash(tohashString)		
			self.send_response(301)
			self.send_header('Content-type','text/html')
			self.end_headers()
			self.wfile.write(default_page(action,inputString,secretString,outputString,tohashString,hashstring))
			return
		except:
			pass