在输入为文本文件(.txt)的情况下,使用RSA加密和解密对文件中的文本进行加密和解密.我如何实现解决方案? [英] Given input as a text file (.txt), encrypt and decrypt the text in the file using RSA encryption and decryption. How do I achieve the solution?

查看:285
本文介绍了在输入为文本文件(.txt)的情况下,使用RSA加密和解密对文件中的文本进行加密和解密.我如何实现解决方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

输入为文本文件(.txt),使用RSA加密和解密对文件中的文本进行加密和解密.

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.

推荐答案

此类的MSDN文档提供了一个精确地做到这一点的示例-加密/解密字符串.

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

还要看一下关于同一主题的该较早主题:

将RSAServiceProvider与字符串一起使用 [
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.


这篇关于在输入为文本文件(.txt)的情况下,使用RSA加密和解密对文件中的文本进行加密和解密.我如何实现解决方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆