2024-05-06 12:55:05 -07:00
|
|
|
import 'package:cake_wallet/core/secure_storage.dart';
|
2023-08-15 03:47:25 +03:00
|
|
|
import 'package:cw_core/cake_hive.dart';
|
2020-01-04 21:31:52 +02:00
|
|
|
|
|
|
|
Future<List<int>> getEncryptionKey(
|
2024-05-08 21:23:27 +01:00
|
|
|
{required String forKey, required SecureStorage secureStorage}) async {
|
2023-08-15 03:47:25 +03:00
|
|
|
final stringifiedKey = await secureStorage.read(key: 'transactionDescriptionsBoxKey');
|
2020-01-04 21:31:52 +02:00
|
|
|
List<int> key;
|
|
|
|
|
|
|
|
if (stringifiedKey == null) {
|
2023-08-15 03:47:25 +03:00
|
|
|
key = CakeHive.generateSecureKey();
|
2020-01-04 21:31:52 +02:00
|
|
|
final keyStringified = key.join(',');
|
2023-11-27 08:28:34 -05:00
|
|
|
String storageKey = 'transactionDescriptionsBoxKey';
|
2024-05-08 21:23:27 +01:00
|
|
|
await secureStorage.write(key: storageKey, value: keyStringified);
|
2020-01-04 21:31:52 +02:00
|
|
|
} else {
|
2023-08-15 03:47:25 +03:00
|
|
|
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
|
2020-01-04 21:31:52 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
2023-08-15 03:47:25 +03:00
|
|
|
}
|