1,105,384 Community Members

Encryption of numbers....

Member Avatar
star320
Newbie Poster
3 posts since Feb 2005
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Can someone please help me where to begin on this problem... I don't want answers, just some guidance:
I have to make a program that reads a 4 digit integer: and encrypt it with a calculation: then swap 1st digit with 3rd, swap 2nd digit with 4th and print the integer; then write another program that inputs the encrypted 4 digit int and decrypt from the original number.
I want to use rand() and srand() to generate the numbers. But, I am also considering an array and create constant numbers to input: I thought that by scrammbling the numbers on input that this would automatically encrypt the numbers... (?): I am confused on where to begin to solve this problem (I do understand the calculation but am stuck on the encryption and decryption issue). Also, I think this problem needs to use a nested approach.... please tell me if I am on the right track: or can you please give me some direction or tell me if I am thinking correctly! I just need some clarity... thank you.
star320

Member Avatar
harshchandra
Junior Poster in Training
68 posts since Nov 2004
Reputation Points: -3 [?]
Q&As Helped to Solve: 1 [?]
Skill Endorsements: 0 [?]
 
0
 

So wats problem in it just swap the digits....that the encrypted one.....and then again swap it back to decrypt

Member Avatar
letmec
Light Poster
33 posts since Sep 2004
Reputation Points: 0 [?]
Q&As Helped to Solve: 2 [?]
Skill Endorsements: 0 [?]
 
0
 

So wats problem in it just swap the digits....that the encrypted one.....and then again swap it back to decrypt

just convert the integer to strint using itoa() function, and then you can easly swape the digit-character. and then conver the this encrypted string back to integer using atoi() function. Visa-versa with decryption.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article