RSA算法的实现 摘 要 本文设计的是一套完整实用的RSA文件加密解决方案,并具体编码实现。本文采用费马小定理测试素数,使用Montgomery加快大数模乘运算,用C++实现RSA加密算法类库,并在32位windows平台封装成组件。在.Net平台引用此组件,实现可以对任意文件进行RSA加密操作的窗体应用程序。经过加密的文件以及密钥文件都是文本文件。本文首先给出关键类类图、整个应用程序的结构描述文档,然后对关键模块流程图、详细的接口文档进行阐述,并给出关键的实现代码,最后对应用程序进行测试,对测试结果进行分析研究,进而对应用程序进行改进,对关键算法进行尽可能的优化,最终得到一个在windows运行的可以用指定密钥对任意文件进行RSA加密并可解密的完整应用程序,和一些相关的可移植组件。 关键词: RSA;文件加密;Montgomery;费马定理 Implementof RSA Algorithm Abstract In this paper, a solution ofencrypting file with RSA algorithm and the codes of this system are introduced.Fermat theory is used to test prime number. Montgomery is used to cut short the time ofmodular multiplication of large number. The class library of RSA is implementedin C++, and packaged to component on the platform of 32 bits windows. On theplatform of .Net, the application is implemented with reference of thiscomponent and can encrypt any file with RSA. Both encrypted files and key filesare text files. In this paper, core class figures and the framework are firstintroduced. Then the flow of core modules and detail interfaces are stated andthe kernel codes are showed also. Finally, it analyzes the result of test, thenoptimizes core algorithm. In the conclusion, an entire application which canencrypt any files with RSA algorithm using given key and some transplantedcomponents are implemented. Key words: RSA ; File Encryption ; Montgomery; Fermat
|