OpenSSL SDK第一个示例
///////////////////////////////////////////////////////////////////////////////////////
// # @ 老夏课堂 夏曹俊整理
// # openssl.vip
// # 下载路径 http ://openssl.vip/download
// # 文档参考 http ://openssl.vip/docs
// # QQ群 296249312
#include <iostream>
#include <openssl/rand.h>
#include <time.h>
#include <thread>
extern "C"
{
//错误 C4996 'fopen': This function or variable may be unsafe.
//Consider using fopen_s instead.To disable deprecation, use _CRT_SECURE_NO_WARNINGS.See online help for details.first_openssl
#include <openssl/applink.c>
}
using namespace std;
int main()
{
for (;;)
{
//用时间戳做随机数的种子
time_t t = time(0);
RAND_seed(&t,sizeof(t));
//生成随机数
unsigned char buf[16] = { 0 };
int len = sizeof(buf);
int re = RAND_bytes(buf, len);
for (int i = 0; i < len; i++)
{
cout << "["<<(int)buf[i]<<"]";
}
cout << endl;
this_thread::sleep_for(1000ms);
}
return 0;
}