MCPcopy Create free account
hub / github.com/Tencent/MMKV / checkReSetCryptKey

Method checkReSetCryptKey

Core/MMKV.cpp:393–427  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

391}
392
393void MMKV::checkReSetCryptKey(const string *cryptKey, bool aes256) {
394 SCOPED_LOCK(m_lock);
395
396 if (m_crypter) {
397 if (cryptKey && !cryptKey->empty()) {
398 string oldKey = this->cryptKey();
399 if (oldKey != *cryptKey) {
400 MMKVInfo("setting new aes key");
401 delete m_crypter;
402 auto ptr = cryptKey->data();
403 m_crypter = new AESCrypt(ptr, cryptKey->length(), nullptr, 0, aes256);
404
405 checkLoadData();
406 } else {
407 // nothing to do
408 }
409 } else {
410 MMKVInfo("reset aes key");
411 delete m_crypter;
412 m_crypter = nullptr;
413
414 checkLoadData();
415 }
416 } else {
417 if (cryptKey && !cryptKey->empty()) {
418 MMKVInfo("setting new aes key");
419 auto ptr = cryptKey->data();
420 m_crypter = new AESCrypt(ptr, cryptKey->length(), nullptr, 0, aes256);
421
422 checkLoadData();
423 } else {
424 // nothing to do
425 }
426 }
427}
428
429#endif // MMKV_DISABLE_CRYPT
430

Callers 6

checkReSetCryptKeyFunction · 0.45
checkReSetCryptKeyFunction · 0.45
checkReSetCryptKeyFunction · 0.45
checkReSetCryptKeyFunction · 0.45
checkReSetCryptKeyFunction · 0.45
CheckReSetCryptKeyMethod · 0.45

Calls 1

cryptKeyMethod · 0.95

Tested by

no test coverage detected