2023-03-30 22:33:59 +00:00
|
|
|
import 'package:cake_wallet/core/secure_storage.dart';
|
2020-01-04 19:31:52 +00:00
|
|
|
import 'package:hive/hive.dart';
|
|
|
|
|
|
|
|
Future<List<int>> getEncryptionKey(
|
2023-03-30 22:33:59 +00:00
|
|
|
{required String forKey, required SecureStorage secureStorage}) async {
|
2020-01-04 19:31:52 +00:00
|
|
|
final stringifiedKey =
|
|
|
|
await secureStorage.read(key: 'transactionDescriptionsBoxKey');
|
|
|
|
List<int> key;
|
|
|
|
|
|
|
|
if (stringifiedKey == null) {
|
|
|
|
key = Hive.generateSecureKey();
|
|
|
|
final keyStringified = key.join(',');
|
|
|
|
await secureStorage.write(
|
|
|
|
key: 'transactionDescriptionsBoxKey', value: keyStringified);
|
|
|
|
} else {
|
|
|
|
key = stringifiedKey
|
|
|
|
.split(',')
|
|
|
|
.map((i) => int.parse(i))
|
|
|
|
.toList();
|
|
|
|
}
|
|
|
|
|
|
|
|
return key;
|
|
|
|
}
|