1
0
mirror of https://github.com/stefanocasazza/ULib.git synced 2025-10-26 19:57:22 +08:00
This commit is contained in:
stefanocasazza
2016-07-13 14:53:28 +02:00
parent 4a1bb9f1e3
commit fe81d747a3
10 changed files with 46 additions and 11 deletions

View File

@@ -176,6 +176,20 @@ struct U_EXPORT UServices {
static void generateDigest(int alg, uint32_t keylen, const UString& data, UString& output, int base64 = 0)
{ generateDigest(alg, keylen, (unsigned char*)U_STRING_TO_PARAM(data), output, base64); }
static UString generateCode(uint32_t len = 6)
{
U_TRACE(0, "UServices::generateCode(%u)", len)
UString code(len);
char* ptr = code.data();
for (uint32_t i = 0; i < len; ++i, ++ptr) *ptr = u_alphabet[u_get_num_random(sizeof(u_alphabet) - 3)];
code.size_adjust(len);
U_RETURN_STRING(code);
}
#ifdef USE_LIBSSL
static UString createToken(int alg = U_HASH_SHA256);