fil = "/sdcard/index.html"
file = app.CreateFile( fil,"r" );
data = file.ReadData(4.875*1024,"hex");
file.Clos);
enc = crp.Encrypt (data );
now I get the encrypted data but how to insert it to the original file and replace its first 4kb data with encrypted data...?
You'll need to create a new file and using the "rw" option of CreateFile, put the encrypted dats in it, then read the rest of the data from the old file and add it to the new one. Both writes will be best accomplished using WriteData.
If you manage that you will have a similarly interesting time reconstructing the file when you decrypt.
I wouldn't recommend this process but I don't know what you are trying to achieve. Is there some reason why you can't send the encrypted bit and the plsin binary as separate files?
I tried the aforementioned method, It works fine but if the file is more than 25mb it either stops responding or takes too much longer time...
I would like to ask if there is any other method to corrupt the file and again making it useable...
ie
var src = "abcdef";
var dst = [];
const buflen = 3;
//encrypt
var encrypt = btoa;
for(var i=0; i<src.length; i+=buflen) {
dst.push(encrypt(src.slice(i, i+buflen)));
}
dst = dst.join(";");
alert(dst);
//decrypt
var decrypt = atob;
src = dst.split(";");
dst = src.map(decrypt).join("");
alert(dst);