Answer the question
In order to leave comments, you need to log in
PHP encryption and decryption - android. What's wrong?
I encrypt the file and download it, then I decrypt it on the Android device, what could be the problem?
$file = fopen('License.pdf', 'rb');
$size = filesize($file);
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=License');
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate');
header('Pragma: public');
while (!feof($file)) {
// print ($data ^ 4);
$data = fread($file,4096);
if (strlen($data) == 4096) {
for ($i = 0; $i < 4096; $i++) {
$data[$i] = ($data[$i] ^ $data[0]);
}
}
print $data;
}
BufferedInputStream reader = new BufferedInputStream(new FileInputStream(file));
outFile = new File(filesDir, file.getName());
FileOutputStream out = new FileOutputStream(filePath + "_dec_02");
String base = null;
String save = null;
byte[] buffer = new byte[4096];
int size;
char helpKey = 0;
char[] keys = key.toCharArray();
while ((size = reader.read(buffer)) != -1) {
if (size == 4096) {
//
for (int i = 0; i < 4096; i++) {
buffer[i] = (byte) (buffer[i] ^ buffer[0]);
}
}
//
out.write(buffer);
out.flush();
}
Answer the question
In order to leave comments, you need to log in
What did you want to achieve with this "algorithm"?
for ($i = 0; $i < 4096; $i++) {
$data[$i] = ($data[$i] ^ $data[0]);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question