mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-23 03:59:23 +00:00
20 lines
751 B
Dart
20 lines
751 B
Dart
import 'package:cake_wallet/core/secure_storage.dart';
|
|
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
|
import 'package:cw_core/cake_hive.dart';
|
|
|
|
Future<List<int>> getEncryptionKey(
|
|
{required String forKey, required FlutterSecureStorage 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 writeSecureStorage(secureStorage, key: storageKey, value: keyStringified);
|
|
} else {
|
|
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
|
|
}
|
|
|
|
return key;
|
|
}
|