Last active
June 5, 2021 20:46
-
-
Save VB10/b3d5b75d215773e270acfafaa7df1eaf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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