cake_wallet/lib/entities/get_encryption_key.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

21 lines
716 B
Dart

import 'package:cake_wallet/core/secure_storage.dart';
import 'package:cw_core/cake_hive.dart';
Future<List<int>> getEncryptionKey(
{required String forKey, required SecureStorage secureStorage}) async {
final stringifiedKey =
await secureStorage.read(key: 'transactionDescriptionsBoxKey');
List<int> key;
if (stringifiedKey == null) {
key = CakeHive.generateSecureKey();
final keyStringified = key.join(',');
String storageKey = 'transactionDescriptionsBoxKey';
await secureStorage.delete(key: storageKey);
await secureStorage.write(key: storageKey, value: keyStringified);
} else {
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
}
return key;
}