CSString CBCrypt::HashBCrypt(const char* password, int iPrefixCode, int iCost) // static { char salt[BCRYPT_HASHSIZE]; char hash[BCRYPT_HASHSIZE]; const char *pcPrefix; switch (iPrefixCode) { default: case 0: pcPrefix = "$2a$"; break; case 1: pcPrefix = "$2b$"; break; case 2: pcPrefix = "$2y$"; break; case 3: pcPrefix = "$1$"; break; case 4: pcPrefix = "_"; break; } if (bcrypt_gensalt(pcPrefix, iCost, salt) != 0) return CSString(); if (bcrypt_hashpw(password, salt, hash) != 0) return CSString(); return CSString(hash); }
CSString CSString::mid(unsigned int i, int len) const { if (i > _deqCustString->size() - 1 || len == 0) return CSString(""); CSString temp; unsigned endPointer; if (len < 0 || len > _deqCustString->size() - 1 || len > _deqCustString->size() - i) { endPointer = _deqCustString->size() - 1; } else { endPointer = i + len - 1; } for (int j = i; j <= endPointer; j++) { temp._deqCustString->push_back((*_deqCustString)[j]); } return temp; }
/* * Make a result string */ inline CSString CWordsDictionary::makeResult( const CSString key, const CSString word ) { CSString res = key + CSString(": ") + word; return res; }
void CDataBaseAsyncHelper::addQuery(bool isQuery, lpctstr sFunction, lpctstr sQuery) { SimpleThreadLock stlThelock(m_queryMutex); m_queriesTodo.push_back( QueryBlob_t(isQuery, FunctionQueryPair_t(CSString(sFunction), CSString(sQuery))) ); }