cake_wallet/lib/core/key_service.dart

32 lines
1.1 KiB
Dart
Raw Normal View History

import 'package:cake_wallet/core/secure_storage.dart';
2020-09-21 11:50:26 +00:00
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cake_wallet/entities/encrypt.dart';
2020-07-06 20:09:03 +00:00
class KeyService {
KeyService(this._secureStorage);
final SecureStorage _secureStorage;
2020-07-06 20:09:03 +00:00
2022-10-12 17:09:57 +00:00
Future<String> getWalletPassword({required String walletName}) async {
final key =
generateStoreKeyFor(key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
final encodedPassword = await _secureStorage.read(key: key);
2022-10-12 17:09:57 +00:00
return decodeWalletPassword(password: encodedPassword!);
2020-07-06 20:09:03 +00:00
}
2022-10-12 17:09:57 +00:00
Future<void> saveWalletPassword({required String walletName, required String password}) async {
final key =
generateStoreKeyFor(key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
2020-07-06 20:09:03 +00:00
final encodedPassword = encodeWalletPassword(password: password);
await _secureStorage.write(key: key, value: encodedPassword);
2020-07-06 20:09:03 +00:00
}
2023-07-12 23:20:11 +00:00
Future<void> deleteWalletPassword({required String walletName}) async {
final key =
generateStoreKeyFor(key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
2023-07-12 23:20:11 +00:00
await _secureStorage.delete(key: key);
}
2020-07-06 20:09:03 +00:00
}