Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #By Mr.A a.k.a A-MAN
- #
- #All rights for this code are reserved for the only creator.
- #
- #Feel free to use any part of this code, but don't claim as your own.
- #
- #CopyRights 2011-2012 by Mr.A
- from Tkinter import *
- import tkMessageBox
- import sys, os
- try:
- class bin2ascii:
- def cal(self, asd):
- asd = asd.replace('0b', '')
- num = asd[::-1]
- MultOfTwo= [1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072]
- value= ''
- for i in range(len(num)):
- additives = int(num[i])* int(MultOfTwo[i])
- value += str(additives) + '+'
- else:
- value += '0'
- return eval(value)
- b2a = bin2ascii()
- def toBinary(decimalNumber):
- quotient = 1
- remainder = 0
- tmpNum = decimalNumber
- finalNumberList = []
- n = ""
- while quotient != 0:
- remainder = decimalNumber % 2
- quotient = decimalNumber / 2
- decimalNumber = quotient
- finalNumberList.insert( 0, remainder )
- for num in finalNumberList:
- n += str( num )
- return n
- class crypter:
- def encrypt(self, text, key):
- OEtext = ''
- DText = text[:]
- DText = DText[::-1]
- for letter in DText:
- FakeAsciiVal = ord(letter) + int(key)
- while FakeAsciiVal > 126:
- FakeAsciiVal -= 96
- BiVal = toBinary(FakeAsciiVal)
- BiVal = BiVal.replace('0b', '')
- OELetter = BiVal
- OELetter = OELetter.replace('1', '\'')
- OELetter = OELetter.replace('0', ',')
- OELetter += '`'
- OEtext += OELetter
- DecryptionBox.insert('end', OEtext)
- def decrypt(self, text, key):
- EText = text[:]
- code = ''
- EText = EText.replace('\'', '1')
- EText = EText.replace(',', '0')
- EText = EText.replace(' ', '')
- ELetter = ''
- DText = ''
- for EByte in EText:
- if EByte != '`':
- ELetter += EByte
- else:
- EWord = ELetter[:]
- b2a = bin2ascii()
- code = int(b2a.cal(EWord)) - int(key)
- while code < 32:
- code += 96
- DText += chr(code)
- EWord = ''
- ELetter = ''
- EncryptionBox.insert('end', DText[::-1])
- crypter= crypter()
- def encryption():
- global key
- text = EncryptionBox.get('1.0', 'end')
- text = text.replace('\n', '')
- key = v.get()
- crypter.encrypt(text, key)
- return
- def decryption():
- global key
- text = DecryptionBox.get('1.0', 'end')
- text = text.replace('\n', '')
- key = v.get()
- crypter.decrypt(text, key)
- return
- root = Tk()
- root.title("A-Crypter V.1.01")
- root.geometry("600x350")
- w = Label(root, text="A-Crypter v.1.01", fg = 'red', bg = 'blue')
- w.pack()
- v = StringVar()
- v.set("5")
- KeyBox = Entry(root, textvariable=v)
- KeyBox.pack()
- messagekey = Label(root, text="the key must be between (1, 94)", fg = 'red')
- messagekey.pack()
- EncryptionBox=Text(root, width=40, height=20)
- EncryptionBox.pack(side = LEFT)
- DecryptionBox=Text(root, width=40, height=20)
- DecryptionBox.pack(side = RIGHT)
- key = v.get()
- frame = Frame(root)
- frame.pack(side = BOTTOM)
- Encryptbutton = Button(frame, text = 'Encrypt', fg = 'red', command = encryption)
- Decryptbutton = Button(frame, text = 'Decrypt', fg = 'blue', command = decryption)
- Encryptbutton.pack(side = LEFT)
- Decryptbutton.pack(side = RIGHT)
- root.mainloop()
- except:
- tkMessageBox.showwarning(title="Error", message = "An error has occured. Sorry for the inconveinience. Please contact the creator.")
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement