增加一个native生成uuid的方法

This commit is contained in:
cebgcontract 2022-07-25 16:04:15 +08:00
parent 6c3f960907
commit a642639485
4 changed files with 7 additions and 12 deletions

View File

@ -1944,7 +1944,7 @@
ENABLE_BITCODE = YES;
EXCLUDED_ARCHS = "";
EXECUTABLE_PREFIX = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "../cocos/platform/ios/cocos2d-prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = (

View File

@ -762,7 +762,6 @@ static bool JSB_cryptoScrypt(se::State& s)
size_t argc = args.size();
if (argc == 6)
{
std::string ret_val;
bool ok = true;
std::string password;
ok = seval_to_std_string(args[0], &password);

View File

@ -51,7 +51,7 @@ int crypto_scrypt_base64(std::string *password, std::string *salt, uint64_t N,
}
std::string get_uuid() {
void get_uuid(char *buffer) {
static std::random_device dev;
static std::mt19937 rng(dev());
@ -67,18 +67,14 @@ std::string get_uuid() {
res << v[dist(rng)];
res << v[dist(rng)];
}
return res.str();
res >> buffer;
}
std::string uuid_v4() {
char uuidv4[38];
int rc = uuid_v4_gen(uuidv4);
void uuid_v4(char *buffer) {
int rc = uuid_v4_gen(buffer);
if (rc == 1) {
std::stringstream ss;
ss << uuidv4;
return ss.str();
} else {
return get_uuid();
get_uuid(buffer);
}
}

View File

@ -49,6 +49,6 @@ int fast_crypto_scrypt(const uint8_t *passwd, size_t passwdlen, const uint8_t *s
int crypto_scrypt_base64(std::string *password, std::string *salt, uint64_t N,
uint32_t r, uint32_t p, size_t size, std::string *value);
std::string uuid_v4();
void uuid_v4(char *buffer);
#endif // native_crypto_h