增加一个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; ENABLE_BITCODE = YES;
EXCLUDED_ARCHS = ""; EXCLUDED_ARCHS = "";
EXECUTABLE_PREFIX = ""; EXECUTABLE_PREFIX = "";
GCC_GENERATE_DEBUGGING_SYMBOLS = NO; GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES; GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "../cocos/platform/ios/cocos2d-prefix.pch"; GCC_PREFIX_HEADER = "../cocos/platform/ios/cocos2d-prefix.pch";
GCC_PREPROCESSOR_DEFINITIONS = ( GCC_PREPROCESSOR_DEFINITIONS = (

View File

@ -762,7 +762,6 @@ static bool JSB_cryptoScrypt(se::State& s)
size_t argc = args.size(); size_t argc = args.size();
if (argc == 6) if (argc == 6)
{ {
std::string ret_val;
bool ok = true; bool ok = true;
std::string password; std::string password;
ok = seval_to_std_string(args[0], &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::random_device dev;
static std::mt19937 rng(dev()); static std::mt19937 rng(dev());
@ -67,18 +67,14 @@ std::string get_uuid() {
res << v[dist(rng)]; res << v[dist(rng)];
res << v[dist(rng)]; res << v[dist(rng)];
} }
return res.str(); res >> buffer;
} }
std::string uuid_v4() { void uuid_v4(char *buffer) {
char uuidv4[38]; int rc = uuid_v4_gen(buffer);
int rc = uuid_v4_gen(uuidv4);
if (rc == 1) { if (rc == 1) {
std::stringstream ss;
ss << uuidv4;
return ss.str();
} else { } 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, 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); 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 #endif // native_crypto_h