mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-18 00:06:10 +08:00
文件下载&&解压缩接口
This commit is contained in:
54
ios/RCTHotUpdate/SSZipArchive/aes/entropy.c
Executable file
54
ios/RCTHotUpdate/SSZipArchive/aes/entropy.c
Executable file
@@ -0,0 +1,54 @@
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
int entropy_fun(unsigned char buf[], unsigned int len)
|
||||
{
|
||||
HCRYPTPROV provider;
|
||||
unsigned __int64 pentium_tsc[1];
|
||||
unsigned int i;
|
||||
int result = 0;
|
||||
|
||||
|
||||
if (CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT))
|
||||
{
|
||||
result = CryptGenRandom(provider, len, buf);
|
||||
CryptReleaseContext(provider, 0);
|
||||
if (result)
|
||||
return len;
|
||||
}
|
||||
|
||||
QueryPerformanceCounter((LARGE_INTEGER *)pentium_tsc);
|
||||
|
||||
for(i = 0; i < 8 && i < len; ++i)
|
||||
buf[i] = ((unsigned char*)pentium_tsc)[i];
|
||||
|
||||
return i;
|
||||
}
|
||||
#else
|
||||
int entropy_fun(unsigned char buf[], unsigned int 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
|
Reference in New Issue
Block a user