| 1 | import 'package:cake_wallet/core/secure_storage.dart'; |
| 2 | import 'package:cw_core/cake_hive.dart'; |
| 3 | |
| 4 | Future<List<int>> getEncryptionKey( |
| 5 | {required String forKey, required SecureStorage secureStorage}) async { |
| 6 | final stringifiedKey = await secureStorage.read(key: 'transactionDescriptionsBoxKey'); |
| 7 | List<int> key; |
| 8 | |
| 9 | if (stringifiedKey == null) { |
| 10 | key = CakeHive.generateSecureKey(); |
| 11 | final keyStringified = key.join(','); |
| 12 | String storageKey = 'transactionDescriptionsBoxKey'; |
| 13 | await secureStorage.write(key: storageKey, value: keyStringified); |
| 14 | } else { |
| 15 | key = stringifiedKey.split(',').map((i) => int.parse(i)).toList(); |
| 16 | } |
| 17 | |
| 18 | return key; |
| 19 | } |