cake_wallet/lib/entities/get_encryption_key.dart
Adegoke David bfb78eded9
CW-599-Extract-Secure-Storage (#1353)
* feat: Modify app to depend on secure storage abstraction instead of the direct package

* chore: Revert command

* Update configure.dart [skip ci]

* Update configure.dart

* Fix conflicts

* clean up and fixes

* minor fix

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-05-08 23:23:27 +03:00

19 lines
661 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.write(key: storageKey, value: keyStringified);
} else {
key = stringifiedKey.split(',').map((i) => int.parse(i)).toList();
}
return key;
}