Skip to content

Instantly share code, notes, and snippets.

@VB10
Last active June 5, 2021 20:46
Show Gist options
  • Save VB10/b3d5b75d215773e270acfafaa7df1eaf to your computer and use it in GitHub Desktop.
Save VB10/b3d5b75d215773e270acfafaa7df1eaf to your computer and use it in GitHub Desktop.
test('Cache Model & Encryption', () async {
final model = ItemModel(id: 1345);
final crypto = EncrypData();
final directory = await getApplicationDocumentsDirectory();
await Directory('${directory.path}').create();
await Directory('${directory.path}/vb2').create();
final path = '${directory.path}/vb2/${model.title}.json';
final file = File(path);
final modelValuesWithCrypto = crypto.crypteFile(model.toString());
await file.writeAsString(modelValuesWithCrypto);
final dcryptedFile = await file.readAsString();
final decryptedModel = ItemModel.fromString(crypto.decryptFile(dcryptedFile));
expect(decryptedModel.id == model.id, true);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment