cake_wallet/lib/core/key_service.dart
OmarHatem 7b20ff0223 Merge branch 'main' of https://github.com/cake-tech/cake_wallet into cw_linux_direct_input_password
 Conflicts:
	cw_monero/ios/Classes/monero_api.cpp
	ios/Podfile.lock
	lib/router.dart
	lib/src/screens/restore/wallet_restore_from_seed_form.dart
	lib/src/screens/restore/wallet_restore_page.dart
	lib/store/settings_store.dart
	lib/view_model/wallet_new_vm.dart
	scripts/android/app_env.sh
	tool/configure.dart
2023-11-27 17:36:58 +02:00

32 lines
1.2 KiB
Dart

import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cake_wallet/entities/secret_store_key.dart';
import 'package:cake_wallet/entities/encrypt.dart';
class KeyService {
KeyService(this._secureStorage);
final SecureStorage _secureStorage;
Future<String> getWalletPassword({required String walletName}) async {
final key = generateStoreKeyFor(
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
final encodedPassword = await _secureStorage.read(key: key);
return decodeWalletPassword(password: encodedPassword!);
}
Future<void> saveWalletPassword({required String walletName, required String password}) async {
final key = generateStoreKeyFor(
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
final encodedPassword = encodeWalletPassword(password: password);
await _secureStorage.delete(key: key);
await _secureStorage.write(key: key, value: encodedPassword);
}
Future<void> deleteWalletPassword({required String walletName}) async {
final key = generateStoreKeyFor(
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
await _secureStorage.delete(key: key);
}
}