secret code program that encrypts messages and then decrypts

This is the place for queries that don't fit in any of the other categories.

secret code program that encrypts messages and then decrypts

Postby mehtamohit1993 » Wed Nov 27, 2013 3:11 am

Hi so this is my question:

Write a secret code program that encrypts messages entered with your own mathematical formula. For this assignment, you will add a “decoder” function to your program using lists. First, update the encoding function so that, as each character is encoded, it is placed in a list. Then, write a new decoding function that, when called, iterates over the list and prints out the original string. This is what I have so far but I'm not sure what I'm doing wrong can get some help please:

Code: Select all
#Encoded Secret Code of the users input message and then decodes it.

encoded = '' "

def encoded_message(message_user):
   
    '''Encodes a message for the user using a mathematical formula based off unicode'''
   
    for a in message_user:
       
        actual_unitary_code = ord(a)
       
        math_formula_change = ((actual_unitary_code * 3) - 13)*2
       
        math_formula_change = str(math_formula_change)
       
        global encoded
       
        encoded = encoded + math_formula_change + ' '
   
    return encoded

def decoded_message(encoded_unicode):

    '''Decodes the message the user gave'''

    for a in encoded_unicode:

        encoded_unicode.append(a)

        a=((a/2)+13)/3

        encoded_unicode = chr(a)

    print(encoded_unicode)


def main():
    '''Asks user what he/she wants to encode and then returns the encoded message after using the unitary code'''

    encoded_list = []
   
    user_message = input("Please enter a message that you want to encode: \n ")
 
    encoded = encoded_message(user_message)

    encoded_list.append(encoded)

    print(encoded_list)

    decoded_message(encoded_list)
   

main()
Last edited by Mekire on Wed Nov 27, 2013 4:14 am, edited 1 time in total.
Reason: First post lock. PLease use code tags. Read "New Users Read This".
mehtamohit1993
 
Posts: 1
Joined: Wed Nov 27, 2013 3:06 am


Re: secret code program that encrypts messages and then decr

Postby Kebap » Wed Nov 27, 2013 11:24 am

mehtamohit1993 wrote:This is what I have so far but I'm not sure what I'm doing wrong can get some help please

How do you know there is something wrong? What output do you see, what output would you expect? Please read the "New user" thread, OK? Thanks.

@mckryall:
Why would you link a site which does not even show the indentation for their codes? Indentation is utterly important.. :mrgreen:
Learn: How To Ask Questions The Smart Way
Join the #python-forum IRC channel on irc.freenode.net and chat with uns directly!
Kebap
 
Posts: 396
Joined: Thu Apr 04, 2013 1:17 pm
Location: Germany, Europe

Re: secret code program that encrypts messages and then decr

Postby micseydel » Wed Nov 27, 2013 6:47 pm

Join the #python-forum IRC channel on irc.freenode.net!

Please do not PM members regarding questions which are meant to be discussed publicly. The point of the forum is so that others can benefit from it. We don't want to help you over PMs or emails.
User avatar
micseydel
 
Posts: 1358
Joined: Tue Feb 12, 2013 2:18 am
Location: Mountain View, CA

Re: secret code program that encrypts messages and then decr

Postby ochichinyezaboombwa » Wed Nov 27, 2013 9:31 pm

... and the reason is, mostly,
mehtamohit1993 wrote: I'm not sure what I'm doing wrong
-- well we neither! because you didn't tell what you think is wrong.
Don't assume we can read minds here (and even if we could we would).
ochichinyezaboombwa
 
Posts: 200
Joined: Tue Jun 04, 2013 7:53 pm


Return to General Coding Help

Who is online

Users browsing this forum: Baidu [Spider] and 2 guests