self.response.out.write("\n")
When I load data from multiline text using the text property and then print it, it prints on one line .... I load the ascii hexa code .... so the carriage return is 0x10, but when assigning it to ascii from the datastore, it’s new no line inserted ... instead it prints as one line
import cgi
print 'Content-Type: text/plain'
print ''
print 'Hello, world!'
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
import operator
class Vault(db.Model):
username=db.StringProperty()
filename=db.StringProperty()
data=db.TextProperty()
op=""
op1=""
username=""
filename=""
class MainPage(webapp.RequestHandler):
def get(self):
stri=""
global username
global filename
stri=""
username = self.request.get("name")
filename=self.request.get("filename")
mac=self.request.get("mac")
mac=mac.replace(':','')
q=db.GqlQuery("SELECT * FROM Vault WHERE filename=:1",filename)
for vault in q:
stri=cgi.escape(vault.data)
s=0
e=12
cycle=len(stri)/12
z=""
for j in range(cycle):
plain=stri[s:e]
s1=0
s2=2
for i in range(6):
x=int(plain[s1:s2],16)
y=int(mac[s1:s2],16)
s1=s1+2
s2=s2+2
z+=chr(operator.xor(x,y))
mac=plain
s=s+12
e=e+12
print z
application = webapp.WSGIApplication([('/dec', MainPage)],debug=True)
def main():
run_wsgi_app(application)
if __name__ == "__main__":
main()
source
share