dump method

Future<bool> dump()

Fonction permettant de chiffrer le SecureStorage et d'écrire le fichier chiffré sur le disque

Implementation

Future<bool> dump() async{
  if (!_secureStorageReadStatus){
    logger("$dumpDebugHeader - FALSE RETURN : SecureStorage was correctly initialized but data from file wasn't correctly parsed");
    return false;
  }
  if (_secureStorageIV == null || _secureStorageKey == null || _encrypter == null || _encryptedSecureStorageKey == null){
    logger("$dumpDebugHeader - FALSE RETURN : Either _secureStorageIV || _secureStorageKey || _encrypter || _encryptedSecureStorageKey was null, here is the result");
    logger("$dumpDebugHeader - FALSE RETURN : $_secureStorageIV || $_secureStorageKey || $_encrypter || $_encryptedSecureStorageKey");
    return false;
  }
  Encrypted encrypted = _encrypter!.encrypt(jsonEncode(_data), iv: _secureStorageIV);

  File encryptedFile = File(SECURE_STORAGE_PATH);

  await encryptedFile.writeAsBytes(encrypted.bytes);

  return true;
}