Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (4 votes)
See more:
Given input as a text file (.txt), encrypt and decrypt the text in the file using RSA encryption and decryption.

Part 1:
Input format:
Your program should prompt the user for the following input:
Enter the input file that you want to encrypt:

Program functionality:
The program should:
Select two large primes at random, p and q
Compute n = p x q
Select at random encryption key e
Find decryption key d
Your program must be able to:
Convert each character in the message into ASCII code
Print p, q, e, and d on the screen
Encrypt the message using key {e, n}
Print the encrypted message on the screen
Decrypt the text using key {d, n}
Print the decrypted message on the screen
Part 2:
To check the correctness of the program, the program will accept p, q, and e from keyboard.
In part 2, your program should prompt the user for the following input:
Enter the input file that you want to encrypt:
Enter p :
Enter q:
Enter e:
 \program must be able to:
Convert each character in the message into ASCII code
Encrypt the message using key {e, n}
Print the encrypted message on the screen
Decrypt the text using key {d, n}
Print the decrypted message on the screen
Note:
The text file contains only the letters A-Z and a-z.
Posted
Updated 15-Feb-11 10:55am
v2
Comments
William Winner 15-Feb-11 16:56pm    
We don't do someone else's homework on this site. If you are stuck on a particular bit of code or concept, ask specifically about that. Otherwise, talk to your professor and arrange for a tutor.
Sandeep Mewara 16-Feb-11 1:27am    
Homework it is. Any effort?

1 solution

The MSDN documentation for this class has an example that does precisely that - encrypt/decrypt strings.

http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.aspx[^]

Also look at this earlier thread on the same topic:

Using RSAServiceProvider with string[^]

[Update]
~~~~~~~~~~

Okay, I just realized this is a homework assignment, was not obvious because of the formatting. I reckon the idea is for you to write your own Rsa class then? If so the links I gave may not help you much.
 
Share this answer
 
v2
Comments
Espen Harlinn 16-Feb-11 15:16pm    
Good links, my 5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900