|
-
Sep 28th, 2002, 09:54 AM
#1
Thread Starter
Junior Member
If Not Reverse Mod, Then What???
thanks to those of you that answered my original question... It's good to know that there is no possible answer... but that still leaves me with an unanswered question... My frist question was how do I "unmod" a number that has been moded in the program below.... I now know that it is impossible to write a program that will unmod any random number... perhaps then there is a way to decrypt the originally encrypted message without "un"moding the digits???
Here is the question word for word, let me know what you think!!Maybe I am interpreting it wrong...
"A company wants to trasnmit data over the telephone, but they are concerned that their phones may be tapped. All their data is transmitted as four-digit integers. They have asked you to write a program that encrypts their data so that it may be transmitted more securely. Your program should read a four digit integer entered by the user and encrypt it as follows: Replace each digit by (the sum of that digit plus 7) modulo 10. THen swap the first digit with the third, and swap the second digit with the fourth. Print the encrypted integer. Write a separate program that inputs an encrypted four digit integer and decrypts it to form the original number. "
Here is the code again for the first part of the problem:
Module Module1
Sub Main()
Dim digit As Integer
Dim placeOne, placeTwo, placeThree, placeFour As Integer
Dim oneSwap, twoSwap, threeSwap, fourSwap As Integer
Console.Write("Please enter the four-digit integer: ")
digit = Console.ReadLine()
placeFour = digit \ 1 Mod 10
placeThree = digit \ 10 Mod 10
placeTwo = digit \ 100 Mod 10
placeOne = digit \ 1000 Mod 10
placeOne = (placeOne + placeOne + 7) Mod 10
placeTwo = (placeTwo + placeTwo + 7) Mod 10
placeThree = (placeThree + placeThree + 7) Mod 10
placeFour = (placeFour + placeFour + 7) Mod 10
oneSwap = placeThree
twoSwap = placeFour
threeSwap = placeOne
fourSwap = placeTwo
Console.WriteLine(oneSwap & twoSwap & threeSwap & fourSwap)
End Sub
End Module
Thank you in advance to anyone who helps me with this thing!!!! I'm new at this, and I'm not much of a logical thinker really...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|