RNCryptorNative
RNCryptorNative copied to clipboard
Procedure to decrypt an AssetFileDescripter
I'm trying to decrypt an encrypted file in the assets directory. I'm loading it with AssetManager.openFd()
and using this method to get the String
:
private String readBytes(AssetFileDescriptor file){
int size = (int) file.getLength();
byte[] bytes = new byte[size];
try {
BufferedInputStream buf = new BufferedInputStream(file.createInputStream());
buf.read(bytes, 0, bytes.length);
buf.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return new String(bytes);
}
This returned string is used in the rnCryptorNative.decrypt(String, password)
method. It always returns an empty String. I'm able to decrypt these same files in an Xcode project using RNCryptor
just fine. Any suggestions to get this working?