Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import webapp2
- form = """
- <html><head><title>Rot13</title></head>
- <body class="html">
- <br />
- <a href="http://facebook.com/princennamdio" target="_blank"><img src="http://cdn1.iconfinder.com/data/icons/socialnetworking/32/facebook.png" /></a>
- <a href="https://twitter.com/princen" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @princen</a>
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
- <br>
- <div align="center">
- <h1>RoT-13 Cipher tool</h1>
- <a href="/">Reload</a>
- <p>
- The simple Caesar-cypher encryption that replaces each English letter with the one 13 places forward or back along the alphabet, so that "The butler did it!" becomes "Gur ohgyre qvq vg!" Most Usenet news reading and posting programs include a rot13 feature. It is used to enclose the text in a sealed wrapper that the reader must choose to open -- e.g., for posting things that might offend some readers, or spoilers. A major advantage of rot13 over rot(N) for other N is that it is self-inverse, so the same code can be used for encoding and decoding.
- <form action="/do" method="post">
- <textarea name="q" rows="10" cols="90">
- %s
- </textarea>
- <br />
- <input type="submit" value="RoT!" class="button"/>
- </form>
- <p>
- </div>
- Result:
- <div style="border:double;">
- <div style="color: grey; padding-left:30px; padding-right:30px; padding-top:30px; padding-bottom:30px; "><strong>%s</strong></div>
- </div>
- <style>
- .button{
- background: #222;
- display: inline-block;
- padding: 5px 30px 6px;
- color: #fff;
- text-decoration: none;
- font-weight: bold;
- line-height: 1;
- -moz-border-radius: 5px;
- -webkit-border-radius: 5px;
- -moz-box-shadow: 0 1px 3px #999;
- -webkit-box-shadow: 0 1px 3px #999;
- text-shadow: 0 -1px 1px #222;
- border-bottom: 1px solid #222;
- position: relative;
- cursor: pointer;
- }
- .html {
- background: url("http://files.simurai.com/tumblr/img/bg.gif") repeat fixed 0 0 transparent;
- text-shadow: #fff 0 1px 0;
- font-family: "Georgia", serif;
- }
- </stylle>
- </body>
- </html>
- """
- class MainHandler(webapp2.RequestHandler):
- def get(self):
- q=w=""
- self.response.out.write('Written By Prince Nnamdi Orafu')
- self.response.out.write(form %(q,w))
- class Doit(webapp2.RequestHandler):
- def post(self):
- q= self.request.get("q")
- w = q.encode("rot13")
- self.response.out.write('Written By Prince Nnamdi Orafu')
- self.response.out.write(form %(q,w))
- def nl2br(string, is_xhtml= True ):
- if is_xhtml:
- return string.replace('\n','<br />\n')
- else :
- return string.replace('\n','<br>\n')
- app = webapp2.WSGIApplication([('/', MainHandler),
- ('/do', Doit)],
- debug=True)
Advertisement
Add Comment
Please, Sign In to add comment