fix(lockscreen): correct main.cpp injection anchor and early-return guard
This commit is contained in:
1 parent
e7618d5e51
commit
53d7149691
7 files changed
+7
-17
No files matched your search
@@ -0,0 +1,40 @@
|
||||
#include "LockscreenPlugin.h"
|
||||
|
||||
namespace LockscreenPlugin {
|
||||
|
||||
const char* modeName(LockscreenMode mode) {
|
||||
switch (mode) {
|
||||
case LockscreenMode::ENABLED: return "Enabled";
|
||||
default: return "Disabled";
|
||||
}
|
||||
}
|
||||
|
||||
bool shouldLock(LockscreenMode mode) {
|
||||
return mode == LockscreenMode::ENABLED;
|
||||
}
|
||||
|
||||
bool shouldLockOnWake(LockscreenMode mode) {
|
||||
return shouldLock(mode);
|
||||
}
|
||||
|
||||
bool shouldLockOnPower(LockscreenMode mode) {
|
||||
return shouldLock(mode);
|
||||
}
|
||||
|
||||
void hashPin(const char* pin, char outHash[9]) {
|
||||
uint32_t hash = 5381;
|
||||
for (const char* p = pin; *p; p++) {
|
||||
hash = ((hash << 5) + hash) ^ static_cast<uint8_t>(*p);
|
||||
}
|
||||
hash ^= 0xA3F1C2B4u;
|
||||
snprintf(outHash, 9, "%08X", hash);
|
||||
}
|
||||
|
||||
bool checkPin(const char* pin, const char* storedHash) {
|
||||
if (!pin || !storedHash || storedHash[0] == '\0') return false;
|
||||
char computed[9];
|
||||
hashPin(pin, computed);
|
||||
return strncmp(computed, storedHash, 9) == 0;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user