Skip to content
This repository was archived by the owner on Aug 4, 2021. It is now read-only.
This repository was 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

@MRodriguess

Description

@MRodriguess

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions