removed a bit of code smell
This commit is contained in:
parent
7f19262325
commit
3f21637876
1 changed files with 8 additions and 8 deletions
|
@ -188,7 +188,7 @@ public class ClientHandler extends Thread {
|
|||
if (result >= 0 || result == -2) {
|
||||
System.out.println("Client is valid");
|
||||
dos.writeInt(result);
|
||||
Map<Map<String, byte[]>, byte[]> data = new HashMap<>();
|
||||
HashMap<String, byte[]> data = new HashMap<>();
|
||||
|
||||
try (ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream(SocketHandler.clientFileData))) {
|
||||
ZipEntry zipEntry;
|
||||
|
@ -201,21 +201,21 @@ public class ClientHandler extends Thread {
|
|||
bos.write(buffer, 0, len);
|
||||
}
|
||||
bos.close();
|
||||
Map<String, byte[]> dataLocal = new HashMap<>();
|
||||
byte[] keyData = SecureRandom.getSeed(256);
|
||||
dataLocal.put(zipEntry.getName(), new Key(keyData).encryptByte(bos.toByteArray()));
|
||||
data.put(dataLocal, keyData);
|
||||
data.put(zipEntry.getName(), bos.toByteArray());
|
||||
}
|
||||
}
|
||||
|
||||
dos.writeInt(data.size());
|
||||
|
||||
for (Map.Entry<Map<String, byte[]>, byte[]> mapEntry : data.entrySet()) {
|
||||
Map.Entry<String, byte[]> entry = mapEntry.getKey().entrySet().iterator().next();
|
||||
SecureRandom rand = new SecureRandom();
|
||||
|
||||
for (Map.Entry<String, byte[]> entry : data.entrySet()) {
|
||||
String className = entry.getKey(); //Name
|
||||
byte[] classData = entry.getValue(); //Data
|
||||
byte[] cryptKey = mapEntry.getValue(); //Key
|
||||
byte[] cryptKey = new byte[256];
|
||||
rand.nextBytes(cryptKey);
|
||||
Key k = new Key(cryptKey);
|
||||
classData = k.encryptByte(classData);
|
||||
|
||||
byte[] encryptedBytes = key.encryptByte(aesE.doFinal(className.getBytes()));
|
||||
dos.writeInt(encryptedBytes.length);
|
||||
|
|
Loading…
Add table
Reference in a new issue