DES加密算法自动填充c++实现
时间: 2023-10-29 11:05:31 浏览: 61
以下是DES加密算法自动填充的C++实现代码:
```c++
#include <iostream>
#include <cstring>
#include <openssl/des.h>
using namespace std;
int main()
{
DES_cblock key = {0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef};
DES_key_schedule schedule;
DES_set_key_checked(&key, &schedule);
const unsigned char input[] = "hello world";
unsigned char output[1024];
memset(output, 0, sizeof(output));
DES_cblock iv = {0x12, 0x34, 0x56, 0x78, 0x90, 0xab, 0xcd, 0xef};
DES_ncbc_encrypt(input, output, sizeof(input), &schedule, &iv, DES_ENCRYPT);
cout << "Encrypted text: ";
for (size_t i = 0; i < sizeof(input); ++i)
cout << hex << (int)output[i];
cout << endl;
return 0;
}
```
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)