1. #1
    Will Watts's Avatar
    Join Date
    Mar 2012
    Location
    %tmp%
    Posts
    5,189
    • specs System Specs
      • Manufacturer:
        Alienware M15x
      • Model Number:
        M15x
      • CPU:
        i5 520 M @ 2.40GHz
      • Memory:
        8GB
      • Graphics:
        ATI Radeon HD 5800
      • Hard Drives:
        720GB 7200 rpm
      • Operating System:
        Windows 8 + Ubuntu

    CYPHER - Python

    This is a very simple program, but one of my first proper programs that actually does something - albeit not that useful... unless you're a spy. I would have to write a security related program ....

    CYPHER - Creates a secret "code" using an XOR Cypher. Cypher key is a typed password, which is then used to produce the coded or decoded output.

    CYPHER - Python-cypher1-jpg

    CYPHER - Python-cypher2-jpg

    I've updated the program to display *'s in the Password box, after rummaging through the tkinter references.

    Code:
    # Cypher v1.0
    # Python version 3.2
    #
    # Created by Will Watts
    # Secret Code generator using a XOR cypher.
    
    from tkinter import *
    from itertools import zip_longest
    
    class Application(Frame):
        """ GUI application for XOR Cypher. """
        def __init__(self, master):
            """ Initialize Frame. """
            super(Application, self).__init__(master)
            self.grid()
            self.create_widgets()
    
        def create_widgets(self):
            """ Create widgets to get password and message and display code. """
            #Instruction label
            Label(self,
                  text = "CYPHER"
                  ).grid(row = 0, column = 0, sticky = W)
    
            #password label
            Label(self,
                  text = "Password:"
                  ).grid(row = 3, column = 0, sticky = W)
            self.password_ent = Entry(self, show="*")
            self.password_ent.grid(row = 3, column = 1, sticky = W)
    
            #message box
            self.message_txt = Text(self,
                                    width = 75,
                                    height = 10,
                                    wrap = WORD)
            self.message_txt.grid(row = 5, column = 0, columnspan = 4)
    
            #cypher button
    
            Button(self,
                   text = "Cypher",
                   command = self.cypher
                   ).grid(row = 8, column = 0, sticky = W)
    
        def cypher(self):
            key = self.password_ent.get()
            data = self.message_txt.get(0.0, END)
    
            coded = ''.join(chr(ord(x) ^ ord(y)) for (x,y) in zip_longest(data, key, fillvalue = '-'))
    
            self.message_txt.delete(0.0, END)
            self.message_txt.insert(0.0, coded)
    
    root = Tk()
    root.title("CYPHER")
    app = Application(root)
    root.mainloop()
    Has Sysnative Forums helped you? Please consider donating to help support the forum.



    • Ad Bot

      advertising
      Beep.

        
       

  2. #2
    GZ's Avatar
    Join Date
    Apr 2012
    Location
    New Jersey
    Posts
    1,923
    • specs System Specs
      • Manufacturer:
        GZ Technologies LLC
      • Model Number:
        Phenom-INAL
      • Motherboard:
        ASUS M5A97-EVO
      • CPU:
        AMD PhenomII x6 (1100T)
      • Memory:
        16GB Kingston Hyper-X blu PC3-12800
      • Graphics:
        XFX Radeon HD6770
      • Sound Card:
        Realtek ALC892
      • Hard Drives:
        500GB WD Caviar Black / 1TB WD Caviar Black / 1TB Seagate / 500GB Hitachi
      • Disk Drives:
        HP DVD 1270i SATA DVD RW
      • Power Supply:
        Corsair 850TX
      • Case:
        Antec 300
      • Cooling:
        Coolermaster V8 / 2x 12CM intake / 1x 12CM rear exhaust / 1x 14CM top exhaust
      • Display:
        Acer 23in 1920x1080 / Acer 20in
      • Operating System:
        Microsoft Windows 8 Professional x64

    Re: CYPHER - Python

    Good job!

    We could use it to post coded messages in an open thread!!!! It will be like writing notes in english runic in Algebra class!!!
    GooonE says thanks for this.

    "Among the tales of sorrow and of ruin that come down to us from the darkness of those days there are yet some in which amid weeping there is joy and under the shadow of death light that endures."

    J.R.R. Tolkien - The Silmarillion

Similar Threads

  1. HiLo Game - Python
    By AceInfinity in forum Programming
    Replies: 2
    Last Post: 02-06-2013, 01:24 AM
  2. Python - Will's Amazing Menu Program
    By Will Watts in forum Programming
    Replies: 10
    Last Post: 07-04-2012, 02:22 AM
  3. Python - I'm stuck.
    By Will Watts in forum Programming
    Replies: 5
    Last Post: 05-23-2012, 03:39 AM
  4. [Python] - Naughts and Crosses/Tic-Tac-Toe
    By Will Watts in forum Programming
    Replies: 2
    Last Post: 05-22-2012, 03:32 PM

Log in

Log in