密码学原理_Crypto++实现RSA加密

来源:互联网 发布:正交矩阵性质 编辑:程序博客网 时间:2024/06/05 01:59

Requirements

请用 Crypto++实现一 个程序,具有加密和解密两种功能。在用加密功能时,读出一个名为“key.txt” 的文件中的 1024 位的密钥,一个名为“plain.txt”的文件中的一段不超过 1000 位的明文,用 RSA 加密后,密文写入一个叫做“encrypted.txt”的文件。在用解密功能时,读出一个名为“key.txt”的文件中的 1024 位的密钥,一个名为 “encrypted.txt”的文件中的密文,用 RSA 解密后,密文写入一个叫做 “decrypted.txt”的文件。所有文件格式均为纯文本,密钥、明文、密文均用 二进制书写,形如“00111010……”。请提交全部源代码。

RSA_Encryption Description

key: 1024 bits from “key.txt”
plaintext: less than 1000 bits from “plain.txt”
ciphertext: “encrypted.txt”
Encryption: RSA
Description: RSA
recovered: “descrypted.txt”

Description

Organization

Source code

.├── README.md├── RSA.cpp├── RSA_Gen.cpp└── test

After executing ./test

Note:

  • “test” contents a series of commands to complie and execute.
  • Current user should own executable permissions on “test” (You may add sudo).
.├── README.md├── RSA├── RSA.cpp├── RSA_Gen├── RSA_Gen.cpp├── d.txt├── descrypted.txt├── e.txt├── encrypted.txt├── key.txt├── plain.txt└── test

Here is an example:

86 bits saved in plain.txt43 byte(s) Random String Generated Successfully in plain.txt1024 bits saved in key.txt1024 bits saved in d.txt8 bits saved in e.txtPlaintext is the following:1G��S`|���E�秫#䬷���Encryption Success. Ciphertext is the following:�~*I�5tbb~~_;L �|��$�Mx57j���E���o�{8xABf7�K��B|z�G�oN�n��w#)��0�FR��Et��4;�x��I���`ېa��s������Hyv��V�I��8�y���C/#Ciphertext is the following:�~*I�5tbb~~_;L �|��$�Mx57j���E���o�{8xABf7�K��B|z�G�oN�n��w#)��0�FR��Et��4;�x��I���`ېa��s������Hyv��V�I��8�y���C/#Descryption Success. Plaintext is the following:1G��S`|���E�秫#䬷���

Source Code

文件有点多

原创粉丝点击