Skip to content
This repository has been archived by the owner on Aug 4, 2021. It is now read-only.

Fail to get the original file after encrypting it and decrypting #52

Open
MRodriguess opened this issue Jan 16, 2019 · 0 comments
Open

Comments

@MRodriguess
Copy link

I am trying to read the database file from a specified app, encrypt it, and save it to external SD CARD.
When I try to get it back, the file contents are not the same.

 //Get databaseFile uncrypted
 byte[] originalDbBytes = storage.readFile("database/path");
 
 //This file is ok
 storage.createFile("path/original/file", originalDbBytes);

 //Add encryption for testing purpose only
 String IVX = "abcdefghijklmnop"; // 16 lenght - not secret
 String SECRET_KEY = "secret1234567890"; // 16 lenght - secret
 byte[] SALT = "0000111100001111".getBytes(); // random 16 bytes array
 EncryptConfiguration configuration = new EncryptConfiguration.Builder()
 .setEncryptContent(IVX, SECRET_KEY, SALT)
 .build();

 //Configure the encription on storage instance
 storage.setEncryptConfiguration(configuration);

 //Create encrypted file.
 storage.createFile("path/encrypted/file", originalDbBytes);

 //Read encripted file.
 byte[] bytes = storage.readFile("path/encrypted/file");

 //Write decrypted file-
 storage.createFile("path/decrypted/file", bytes);

 decrypted file is invalid

Any hints on this? Should this work only with textfiles?
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant