import sys import binascii try: import pygtk pygtk.require("2.0") except: print("Failed to import pygtk.") sys.exit(1) try: import gtk import gtk.glade except: print("GTK Not Availible") sys.exit(1) class MainApp: wTree = None def __init__( self ): self.wTree = gtk.glade.XML( "crypto.glade" ) dic = { "on_windowMain_destroy" : self.quit, "on_bttn_decrypt_clicked" : self.on_bttn_decrypt_clicked } self.private_key = "sGLoX0H2+8TjTY3PQsEk66obR3" self.iv_length = 8 self.key_length = 56 self.wTree.signal_autoconnect( dic ) gtk.main() def quit(self, widget): sys.exit(1) def on_bttn_decrypt_clicked(self, widget): """What to do when they want to decrypt something.""" #Get the widgets. w1 = self.wTree.get_widget("txt_card_code") w2 = self.wTree.get_widget("lbl_plaintext_card_number") w3 = self.wTree.get_widget("lbl_plaintext_card_code") #Extract the code. t1=w1.get_text() #Test that there is something to work on. if not t1: return #Translate the hex string into binary string. t1 = binascii.unhexlify(t1) #Extract the card number and the security code. w2.set_text(t1[:-3]) w3.set_text(t1[-3:]) letsdothis = MainApp()