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.
Jump to Post
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 …
All 2 Replies
harshchandra -3 Junior Poster in Training
letmec 0 Light Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.