mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-11-01 18:07:44 +00:00
26 lines
944 B
Dart
26 lines
944 B
Dart
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||
|
import 'package:cake_wallet/src/domain/common/secret_store_key.dart';
|
||
|
import 'package:cake_wallet/src/domain/common/encrypt.dart';
|
||
|
|
||
|
class KeyService {
|
||
|
KeyService(this._secureStorage);
|
||
|
|
||
|
final FlutterSecureStorage _secureStorage;
|
||
|
|
||
|
Future<String> getWalletPassword({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({String walletName, String password}) async {
|
||
|
final key = generateStoreKeyFor(
|
||
|
key: SecretStoreKey.moneroWalletPassword, walletName: walletName);
|
||
|
final encodedPassword = encodeWalletPassword(password: password);
|
||
|
|
||
|
await _secureStorage.write(key: key, value: encodedPassword);
|
||
|
}
|
||
|
}
|