473,396 Members | 1,915 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Encryption/Decryption Help

32
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,loops,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
Mar 4 '07 #1
13 5894
stroken
24
Post your code and be more specific about your problem.
Mar 4 '07 #2
samimmu
32
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..
Mar 5 '07 #3
lqdeffx
39
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!
Mar 5 '07 #4
RedSon
5,000 Expert 4TB
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
Mar 5 '07 #5
samimmu
32
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.
Mar 7 '07 #6
sicarie
4,677 Expert Mod 4TB
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?
Mar 7 '07 #7
samimmu
32
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
Mar 8 '07 #8
sicarie
4,677 Expert Mod 4TB
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.
Mar 8 '07 #9
timmy
2
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
Mar 8 '07 #10
DeMan
1,806 1GB
Hello Namesake
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?
Mar 9 '07 #11
DeMan
1,806 1GB

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....
Expand|Select|Wrap|Line Numbers
  1. if(inChar + secretKey >126)
  2. {
  3.   newChar = 32 + ((inChar + secretKey) -127);
  4. }
  5. else
  6. {
  7.   newChar = (inChar + secretKey);
  8. }
  9.  
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....
}
Mar 9 '07 #12
samimmu
32
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....
Expand|Select|Wrap|Line Numbers
  1. if(inChar + secretKey >126)
  2. {
  3.   newChar = 32 + ((inChar + secretKey) -127);
  4. }
  5. else
  6. {
  7.   newChar = (inChar + secretKey);
  8. }
  9.  
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]
Mar 10 '07 #13
DeMan
1,806 1GB
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....
Mar 11 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Ralph Freshour | last post by:
I'm having trouble decrypting a file I encrypted and wrote to the server - the following code displays the $decrypted_string variable but the data is still encrypted - any help would be...
2
by: Dave Bailey | last post by:
I have developed a web app using DPAPI to encrypt a connection string in the web.config file. The application works perfectly on the development machine but when deployed to the server when...
2
by: almurph | last post by:
Hi everyone, Can you help me please? I am having a problem with the encryption/decryption of words with the Irish fada in them. The Irish fada is like this: áéíóú/ÁÉÍÓÚ. It's kind of like the...
8
by: manmit.walia | last post by:
Hello Everyone, Long time ago, I posted a small problem I had about converting a VB6 program to C#. Well with the help with everyone I got it converted. But I overlooked something and don't...
4
by: Fritjolf | last post by:
Hi. I've got a strange problem... I've made a simple program to test encryption/decryption. I use Rijndael encryption and here are the most important properties. RijndaelManaged cipher =...
0
by: Dipanwita | last post by:
I have written a RSA encryption/decryption function in c using the formula a = b^c %n. For solving the equation I have used Squaring and multiplying method for modulo exponentiation . These...
3
by: =?Utf-8?B?TG9yZW4=?= | last post by:
I’m trying to encrypt and decrypt a file in vb.net. I am using the TripleDESCryptoServiceProvider encryption found in System.Security.Cryptography. Below is the code for my Encrypt and Decrypt...
5
by: Netwatcher | last post by:
well, i started messing around with dictionaries, yet, most of the pages i found about them always talk about getting only one word out of it and turning it vice versa, i've been playing with that...
9
by: Betikci Boris | last post by:
I get bored last night and wrote a script that uses xor for encrypt- decrypt, however it woks fine under linux 2.6.25, text and documents are ok, but fails on compressed files *.jpg, *.pdf , etc ....
9
by: Alan M Dunsmuir | last post by:
In my (PHP-5) application I have to write some records to a table in my database, which I don't want even my clients using the system to be able to read. This is not a problem in National...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.