mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 06:59:31 +01:00
feat: save hash type with hash in backup
This commit is contained in:
@@ -31,6 +31,7 @@ export default class Backup {
|
||||
|
||||
const db = Object.fromEntries(await this._db.context.readMulti(keys));
|
||||
db.h = md5.hex(JSON.stringify(db));
|
||||
db.ht = "md5";
|
||||
|
||||
if (encrypt) {
|
||||
const key = await this._db.user.key();
|
||||
@@ -89,7 +90,16 @@ export default class Backup {
|
||||
|
||||
_verify(db) {
|
||||
const hash = db.h;
|
||||
const hash_type = db.ht;
|
||||
delete db.h;
|
||||
delete db.ht;
|
||||
switch (hash_type) {
|
||||
case "md5": {
|
||||
return hash == md5.hex(JSON.stringify(db));
|
||||
}
|
||||
default: {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user