From 031ac57368738473f6f6656bbcb6b178f7810560 Mon Sep 17 00:00:00 2001 From: EndMove Date: Tue, 15 Mar 2022 13:49:31 +0100 Subject: [PATCH] =?UTF-8?q?Correction=20FileSize=20Syst=C3=A8me=20de=20has?= =?UTF-8?q?hage=20Sha256=20et=20ajout=20pr=C3=A9cision=20sur=20nom=20de=20?= =?UTF-8?q?l'interface=20si=20celle-ci=20n'est=20pas=20trouv=C3=A9e=20(net?= =?UTF-8?q?=20chooser).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/lightcontainer/App.java | 9 --------- .../main/java/lightcontainer/utils/BCryptHasher.java | 1 - app/src/main/java/lightcontainer/utils/NetChooser.java | 2 +- app/src/main/java/lightcontainer/utils/SHA.java | 10 +++++----- app/src/main/resources/appdata.json | 10 +++++++++- 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/lightcontainer/App.java b/app/src/main/java/lightcontainer/App.java index 8faa7a9..862211f 100644 --- a/app/src/main/java/lightcontainer/App.java +++ b/app/src/main/java/lightcontainer/App.java @@ -20,7 +20,6 @@ import java.nio.file.Paths; public class App { - public static void main(String[] args) { setupVM(); Repository repositoryStorage = prepareStorage(); @@ -37,18 +36,10 @@ public class App { FileFrontEnd ffe = new FileFrontEnd(clientRep, storeRep, protocolRep); new UnicastServerListener(ffe, clientRep, protocolRep, repositoryStorage, repositoryStorage.getUnicastPort()); new MulticastServerListener(ffe, storeRep, protocolRep, repositoryStorage.getMulticastIp(), repositoryStorage.getMulticastPort(), repositoryStorage.getNetworkInterface()); - - // close repo et client et server. - - // Thread.sleep(60000); - - // clientRep.close(); - // storeRep.close(); } private static void initProtocols(Repository repositoryStorage, ProtocolRepository protocolRep) { initReadersProtocols(repositoryStorage, protocolRep); - initWritersProtocols(repositoryStorage, protocolRep); } diff --git a/app/src/main/java/lightcontainer/utils/BCryptHasher.java b/app/src/main/java/lightcontainer/utils/BCryptHasher.java index 91c633e..2a4aafa 100644 --- a/app/src/main/java/lightcontainer/utils/BCryptHasher.java +++ b/app/src/main/java/lightcontainer/utils/BCryptHasher.java @@ -4,7 +4,6 @@ import org.mindrot.jbcrypt.BCrypt; public class BCryptHasher { - public static String hashPassword(String plainTextPassword) { return BCrypt.hashpw(plainTextPassword, BCrypt.gensalt()); } diff --git a/app/src/main/java/lightcontainer/utils/NetChooser.java b/app/src/main/java/lightcontainer/utils/NetChooser.java index 066b7fb..d7ebcbe 100644 --- a/app/src/main/java/lightcontainer/utils/NetChooser.java +++ b/app/src/main/java/lightcontainer/utils/NetChooser.java @@ -59,7 +59,7 @@ public class NetChooser { if(interfaces.size() > 0) { String[] result = new String[interfaces.size()]; for (int i = 0; i < interfaces.size(); ++i) { - result[i] = interfaces.get(i).getDisplayName(); + result[i] = interfaces.get(i).getDisplayName() + " --> " + interfaces.get(i).getName(); } return result; } else diff --git a/app/src/main/java/lightcontainer/utils/SHA.java b/app/src/main/java/lightcontainer/utils/SHA.java index 6eb1c56..0f76efa 100644 --- a/app/src/main/java/lightcontainer/utils/SHA.java +++ b/app/src/main/java/lightcontainer/utils/SHA.java @@ -27,10 +27,10 @@ public class SHA { /* * BORROWING ENCRYPTION DEMO */ - File inFile = new File("D:\\HELMo.txt"); + File inFile = new File("D:\\HELMoCrypted.png"); System.out.println(hashStream( new FileInputStream(inFile), - (int)inFile.length() + inFile.length() )); System.out.println(hashFile( // caca5439dc02f2ced5094e95f1a3403d42127cda29feecd2eb1c68ff38a6fee3 @@ -44,12 +44,12 @@ public class SHA { * * @param in InputStream to the input, flux to hash. * @param fileSize Stream/file size. - *ichier, utilisé + * * @return Borrowing of the full current flux. * * @throws ShaException if an error occur. */ - public static String hashStream(InputStream in, int fileSize) throws ShaException { + public static String hashStream(InputStream in, long fileSize) throws ShaException { StringBuilder sb = new StringBuilder(); byte[] buffer = new byte[1024]; int currentSize = 0; @@ -87,7 +87,7 @@ public class SHA { public static String hashFile(String rootPath, String fileName) throws ShaException { try { File file = new File(String.format("%s/%s", rootPath, fileName)); - return hashStream(new FileInputStream(file), (int)file.length()); + return hashStream(new FileInputStream(file), file.length()); } catch (Exception e) { throw new ShaException(e); } diff --git a/app/src/main/resources/appdata.json b/app/src/main/resources/appdata.json index 2baebe3..aed2e08 100644 --- a/app/src/main/resources/appdata.json +++ b/app/src/main/resources/appdata.json @@ -1 +1,9 @@ -{"unicast_port":8000,"multicast_ip":"224.66.66.1","multicast_port":15502,"network_interface":"","tls":true,"storagePath":"/home/benjamin/ffe","users":[{"name":"aaaaa","password":"$2a$10$nDCEDVwbNO/YDQ4qdRcxfuES4.aboluLzWouXXsk6vDoaWocv516W","aes_key":"kYtwHy9qJBg30WS6axWTFGVE0Ge5kpYiJJlC+COIEI4=","files":[]}]} \ No newline at end of file +{ + "unicast_port": 8000, + "multicast_ip": "224.66.66.1", + "multicast_port": 15502, + "network_interface": "lo", + "tls": true, + "storagePath": "D:\\ffe", + "users": [] +} \ No newline at end of file