This commit is contained in:
Sen
2015-10-29 10:14:32 +08:00
parent c601929993
commit c2bd1bd51b
6 changed files with 400 additions and 502 deletions
+16 -15
View File
@@ -3,12 +3,13 @@
#else
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
#if defined(__cplusplus)
extern "C"
{
#endif
#ifdef _WIN32
int entropy_fun(unsigned char buf[], unsigned int len)
@@ -37,17 +38,17 @@ int entropy_fun(unsigned char buf[], unsigned int len)
#else
int entropy_fun(unsigned char buf[], unsigned int len)
{
int frand = open("/dev/random", O_RDONLY);
int rlen = 0;
if (frand != -1)
{
rlen = read(frand, buf, len);
int frand = open("/dev/random", O_RDONLY);
int rlen = 0;
if (frand != -1)
{
rlen = (int)read(frand, buf, len);
close(frand);
}
return rlen;
}
#endif
#if defined(__cplusplus)
}
#endif
#endif
#if defined(__cplusplus)
}
#endif