tags:

views:

53

answers:

0

i have done the fallowing:

            key_one= int(raw_input("Enter key (0 <= key <= 127): "))#get the user to input the key number

            if key_one in range(128):# to see if the number that the user input is in the given range

                bin_key_one=bin(key_one)[2:]#change the number into binary and remove the 0b from it
                zeros_key=bin_key_one.zfill(7)#add 0 to the beganing og the binary if needed to make it 7-character length 
                print zeros_key
                massage= raw_input("Enter message to be encrypted: ")#get the user to input the massage they want
                for i in massage:
                    massage_ord=ord(i)
                    bin_massage=bin(massage_ord)[2:]

dont know what to do next!

I am trying to do the fallowing:

• Get cipher key (assume user enters integer when prompted for key request)

• Check that value entered is between 0 and 127 inclusive

• Convert integer cipher key to binary string and strip off "0b"

• Check for (and pad beginning with zeros if necessary)

• Get message to be encrypted from standard input

• Initialize encrypted message string to an empty string

• Perform XOR operation on each binary bit of cipher key and message

o Get integer ascii value of each character in message

o Get binary value of ascii version of character and strip off "0b"

o Check for 7-character length (pad beginning with zeros if necessary)

o Perform XOR operation & append binary 7-bit result to encrypted string

 Convert each binary bit of message character and key to an integer

 Perform XOR operation on these two bits

 Convert literal True and False to binary bit & append to output

XOR can be logically implemented as follows:

(a and not b) or (not a and b)

can someone help plz