mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-12-23 11:59:30 +00:00
verify passphrase functionality added to password service
This commit is contained in:
parent
b6613b2fd7
commit
ba853837ce
1 changed files with 27 additions and 0 deletions
|
@ -88,6 +88,33 @@ class DPS {
|
|||
}
|
||||
}
|
||||
|
||||
Future<bool> verifyPassphrase(String passphrase) async {
|
||||
final box = await Hive.openBox<String>(DB.boxNameDesktopData);
|
||||
final keyBlob = DB.instance.get<String>(
|
||||
boxName: DB.boxNameDesktopData,
|
||||
key: _kKeyBlobKey,
|
||||
);
|
||||
await box.close();
|
||||
|
||||
if (keyBlob == null) {
|
||||
// no passphrase key blob found so any passphrase is technically bad
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
await StorageCryptoHandler.fromExisting(passphrase, keyBlob);
|
||||
// existing passphrase matches key blob
|
||||
return true;
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
"${_getMessageFromException(e)}\n$s",
|
||||
level: LogLevel.Warning,
|
||||
);
|
||||
// password is wrong or some other error
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> hasPassword() async {
|
||||
final keyBlob = DB.instance.get<String>(
|
||||
boxName: DB.boxNameDesktopData,
|
||||
|
|
Loading…
Reference in a new issue