From a642639485ec8a1aa4cd5a675914ff8fd2f7ad02 Mon Sep 17 00:00:00 2001 From: cebgcontract <99630598+cebgcontract@users.noreply.github.com> Date: Mon, 25 Jul 2022 16:04:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E4=B8=AAnative?= =?UTF-8?q?=E7=94=9F=E6=88=90uuid=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/cocos2d_libs.xcodeproj/project.pbxproj | 2 +- cocos/scripting/js-bindings/manual/jsb_global.cpp | 1 - cocos/scrypt/native-crypto.cpp | 14 +++++--------- cocos/scrypt/native-crypto.h | 2 +- 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/build/cocos2d_libs.xcodeproj/project.pbxproj b/build/cocos2d_libs.xcodeproj/project.pbxproj index 2a13272..5af3e21 100644 --- a/build/cocos2d_libs.xcodeproj/project.pbxproj +++ b/build/cocos2d_libs.xcodeproj/project.pbxproj @@ -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 = ( diff --git a/cocos/scripting/js-bindings/manual/jsb_global.cpp b/cocos/scripting/js-bindings/manual/jsb_global.cpp index dfa42e3..9abc5ed 100644 --- a/cocos/scripting/js-bindings/manual/jsb_global.cpp +++ b/cocos/scripting/js-bindings/manual/jsb_global.cpp @@ -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); diff --git a/cocos/scrypt/native-crypto.cpp b/cocos/scrypt/native-crypto.cpp index 1f356e8..61288e0 100644 --- a/cocos/scrypt/native-crypto.cpp +++ b/cocos/scrypt/native-crypto.cpp @@ -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); } } diff --git a/cocos/scrypt/native-crypto.h b/cocos/scrypt/native-crypto.h index cec3605..3c4e358 100644 --- a/cocos/scrypt/native-crypto.h +++ b/cocos/scrypt/native-crypto.h @@ -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