![]() |
[Python] Grid encryptor
I failed to complete this in C when I was first starting out, but I think this python program does it well enough.
basically, a word is entered, like hello. The word is padded with *'s to make its length a perfect square. Therefore, input of hello is padded to form hello***. The input is then arranged into a square: h e l l o * * * * and read in reverse: hl*eo*l** :
"""grid-encrypt - Encrypt and Decrypt text using a grid""" |
Text Encrypted: Nr qel.ioWuli*fgoilk*trrt.e*yake * ms Ii*p. w t*
Text decrypted: Nifty program. Works quite well. I like it.****** Edit: It would be nice in the program if the user had the option of entering encrypted text and having it decrypted. Perhaps read from a file even if the message is large enough. |
T etg shIe c a' mth:nlaaha)klbkon*s oisg*.sunee*
|
Reminds me of Sandorf's cipher
|
Looks nice. Sweet stuff. Got to learn that Python sometime...:rolleyes:
|
Quote:
He actually set it up so it would work just as it does for sha1, base64, md5 or any other encryption in Python. :
from base64 import encodestring:
from GridEncrypt import GridEncrypt |
Quote:
Thanks for the compliments everybody. Currently, the program works like this eg: :
g = GridEncrypt()but I'd like to change it the way Sane specified. Give me about 10 minutes :p EDIT: How does one create static methods in python like: :
class GridEncrypt:So it could be called like this: GridEncrypt.encrypt("hello") without creating an object? |
Re: [Python] Grid encryptor
>>>
Massive Bump Alert! >>> I read this thread a year ago when Jessehk made this post, but I never saw his edit. It has taken me almost two full years to find and reply to his edit. Sorry for the delay!! XD Even if he doesn't need it anymore, I bet someone can make a use of my answer. And Jessehk may find the response entertaining, who knows. This is one way to do what you asked: GridEncrypt.py :
class main:my_script.py :
from GridEncrypt import GridEncryptQuote:
But here's the funny part. There's no real point in doing this, because it's not how the base64 module behaves. I messed up in the snippet I posted before. :
from base64 import encodestringThat's how it actually is. So you don't need any "static class" to mimic that behaviour. But there you go anyways. Hahaha. |
| All times are GMT -5. The time now is 9:14 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC