mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-27 05:59:38 +00:00
615d016dd5
* be absolutely sure we delete secure storage keys before writing them * sync with other PR --------- Co-authored-by: fossephate <fosse@book.local> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
20 lines
731 B
Dart
20 lines
731 B
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 secureStorage.delete(key: storageKey);
|
|
await secureStorage.write(key: storageKey, value: keyStringified);
|
|
} else {
|
|
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
|
|
}
|
|
|
|
return key;
|
|
}
|