Encryption/Decryption Help

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samimmu
    New Member
    • Mar 2007
    • 32

    Encryption/Decryption Help

    hi guys



    this is me Sam,actually i a new novice learner in c++ and i haven't gone that further, so far i just studied the basic things,such as definitions,loo ps,and slightly about variables,i have faced a problem when i tried to solve the question which is stated below, i use the ASCCI but i couldn't get properly, i found a lot of bugs in the program, i wish one of guys can respond me as soon as possible.






    Your country is at war and your enemies are using a secret code to
    communicate with each other. You have managed to intercept a message
    that reads as follows:
    :mmZ\dxZmx]Zpgy
    The message is obviously encrypted using the enemy’s secret code. You
    have just learned that their encryption method is based upon the ASCII code.
    Individual characters in a string are encoded using this system. For example,
    TCP1231 Computer Programming 1 Assignment 1
    Page 3 of 6
    the letter “A” is encoded using the number 65 and “B”is encoded using the
    number 66.
    Your enemy’s secret code takes each letter of the message and encrypts it as
    follows:
    If (OriginalChar + Key > 126) then
    EncryptedChar = 32 + ((OriginalChar + Key) - 127)
    Else
    EncryptedChar = (OriginalChar + Key)
    For example, if the enemy uses Key = 10 then the message “Hey” would be
    encrypted as:
    Character ASCII code
    H
    e
    y
    72
    101
    102
    Encrypted H = (72 + 10) = 82 = R in ASCII
    Encrypted e = (101 + 10) = 111 = o in ASCII
    Encrypted y = ((121 + 10) - 127) = 36 = $ in ASCII
    Consequently, “Hey” would be transmitted as “Ro$”.
    Write a program that decrypts the intercepted message. You only know that
    the key used is a number between 1 and 100. Your program should try to
    decode the message using all possible keys between 1 and 100. When you
    try the valid key, the message will make sense.





    Regards:


    sami alkindi



    thank you
  • stroken
    New Member
    • Mar 2007
    • 24

    #2
    Post your code and be more specific about your problem.

    Comment

    • samimmu
      New Member
      • Mar 2007
      • 32

      #3
      that was the code and the problem i couldn't answer it because i have not learn anything, i just learned about the basic things like output and inputs and variables nothing else..

      Comment

      • lqdeffx
        New Member
        • Mar 2007
        • 39

        #4
        so if that is the case, I would suggest researching about loops and converting character's to their ascii values. that should give you all the necessary information, on top of what you already know, to complete that assignment. create something and let us know how it goes!

        Comment

        • RedSon
          Recognized Expert Expert
          • Jan 2007
          • 4980

          #5
          The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve.

          Please read the Posting Guidelines and particularly the Coursework Posting Guidlines.

          Then when you are ready post a new question in this thread.

          MODERATOR

          Comment

          • samimmu
            New Member
            • Mar 2007
            • 32

            #6
            Originally posted by lqdeffx
            so if that is the case, I would suggest researching about loops and converting character's to their ascii values. that should give you all the necessary information, on top of what you already know, to complete that assignment. create something and let us know how it goes!
            thank you anyway,but actually i couldn't answer because i can not get the essential meaning of that question and i have no idea how i start even though i i have not done something that enable me to do it even to start it.

            Comment

            • sicarie
              Recognized Expert Specialist
              • Nov 2006
              • 4677

              #7
              Originally posted by samimmu
              thank you anyway,but actually i couldn't answer because i can not get the essential meaning of that question and i have no idea how i start even though i i have not done something that enable me to do it even to start it.
              So you need to develop a program that will print out 100 messages, each one modifying a value back onto an ASCII value to get a second value?

              Comment

              • samimmu
                New Member
                • Mar 2007
                • 32

                #8
                not really that exactly. i think the question was clear. it is how we decrypt somebody message if he or she using it as his or her privacy.how i can change the word from have a number (78+65) just example how can i decrypt that one.i wish you could help me out ...thank you

                Comment

                • sicarie
                  Recognized Expert Specialist
                  • Nov 2006
                  • 4677

                  #9
                  Originally posted by samimmu
                  Your program should try to
                  decode the message using all possible keys between 1 and 100. When you
                  try the valid key, the message will make sense.
                  Please correct me if I'm wrong, but that looks like 100 messages to me, and then the user will have to decipher it personally.

                  As I see it, the trick to this program is reading in a character, figuring out its ASCII value, and then either adding a number to it, or doing the simple calculation required. If you read in all the chars and figure out their values, then put that into an array, you can use a single for loop to get through the modification and printing.

                  Comment

                  • timmy
                    New Member
                    • Mar 2007
                    • 2

                    #10
                    friends...
                    i want a c++ code for image encryption and decryption ..i will grateful if u can send me on <email removed as per Posting Guidelines
                    Last edited by sicarie; Mar 8 '07, 08:09 PM. Reason: Removed email address per FAQ

                    Comment

                    • DeMan
                      Top Contributor
                      • Nov 2006
                      • 1799

                      #11
                      Hello Namesake
                      Originally posted by timmy
                      i want a c++ code for image encryption and decryption ..i will grateful if u can send me on
                      Ceaser Cipher?
                      RSA?
                      ECC?
                      AES?
                      maybe some Quantum Encryption?

                      Comment

                      • DeMan
                        Top Contributor
                        • Nov 2006
                        • 1799

                        #12
                        Originally posted by samimmu

                        Your country is at war and your enemies are using a secret code to
                        communicate with each other. You have managed to intercept a message
                        that reads as follows:
                        :mmZ\dxZmx]Zpgy
                        The message is obviously encrypted using the enemy’s secret code. You
                        have just learned that their encryption method is based upon the ASCII code.
                        Individual characters in a string are encoded using this system. For example,
                        TCP1231 Computer Programming 1 Assignment 1
                        Page 3 of 6
                        the letter “A” is encoded using the number 65 and “B”is encoded using the
                        number 66.
                        Your enemy’s secret code takes each letter of the message and encrypts it as
                        follows:
                        If (OriginalChar + Key > 126) then
                        EncryptedChar = 32 + ((OriginalChar + Key) - 127)
                        Else
                        EncryptedChar = (OriginalChar + Key)
                        For example, if the enemy uses Key = 10 then the message “Hey” would be
                        encrypted as:
                        Character ASCII code
                        H
                        e
                        y
                        72
                        101
                        102
                        Encrypted H = (72 + 10) = 82 = R in ASCII
                        Encrypted e = (101 + 10) = 111 = o in ASCII
                        Encrypted y = ((121 + 10) - 127) = 36 = $ in ASCII
                        Consequently, “Hey” would be transmitted as “Ro$”.
                        Write a program that decrypts the intercepted message. You only know that
                        the key used is a number between 1 and 100. Your program should try to
                        decode the message using all possible keys between 1 and 100. When you
                        try the valid key, the message will make sense.

                        Seen very similar post recently....

                        (My country is at war....that narrows it down a little)

                        The letter "A" is encoded using the number 65.....sounds like ASCII,
                        The Number "B" is encoded using the number 66...Wait a minute there's a pattern



                        okie....now I've had my game./....
                        we have some pretty specific rules....
                        Code:
                        if(inChar + secretKey >126)
                        {
                          newChar = 32 + ((inChar + secretKey) -127);
                        }
                        else
                        {
                          newChar = (inChar + secretKey);
                        }
                        So we know how this message would be encrypted....

                        how would you decrypt this knowing the secret key?
                        maybe you could try first decrypting a known key.....

                        After that, you know the range of keys......
                        so you could try each one until one kives a good rresult....
                        }

                        Comment

                        • samimmu
                          New Member
                          • Mar 2007
                          • 32

                          #13
                          i am really grateful for you. i will try it, and thanks alot...


                          (My country is at war....that narrows it down a little)

                          The letter "A" is encoded using the number 65.....sounds like ASCII,
                          The Number "B" is encoded using the number 66...Wait a minute there's a pattern



                          okie....now I've had my game./....
                          we have some pretty specific rules....
                          Code:
                          if(inChar + secretKey >126)
                          {
                            newChar = 32 + ((inChar + secretKey) -127);
                          }
                          else
                          {
                            newChar = (inChar + secretKey);
                          }
                          So we know how this message would be encrypted....

                          how would you decrypt this knowing the secret key?
                          maybe you could try first decrypting a known key.....

                          After that, you know the range of keys......
                          so you could try each one until one kives a good rresult....
                          }[/QUOTE]

                          Comment

                          • DeMan
                            Top Contributor
                            • Nov 2006
                            • 1799

                            #14
                            Re the PM:

                            what doesn't work in this code?
                            This doesn't do everyhting you may want, it actually mimics the encryption process (That is, this code should help you to turn hey into Ro$)....

                            But once you can encrypt, you should be able to decrypt using an opposite method....

                            The key to solving the problem, is to understand the process involved, so once you understand how the encryption works, it should help you to understand the decryption.....

                            If you are still unsure on how to proceed, please post again, but please try to wxplain what it is that you don't understand....

                            Comment

                            Working...