Correction FileSize Système de hashage Sha256 et ajout précision sur nom de l'interface si celle-ci n'est pas trouvée (net chooser).
This commit is contained in:
parent
1a91271324
commit
031ac57368
@ -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);
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import org.mindrot.jbcrypt.BCrypt;
|
||||
|
||||
public class BCryptHasher {
|
||||
|
||||
|
||||
public static String hashPassword(String plainTextPassword) {
|
||||
return BCrypt.hashpw(plainTextPassword, BCrypt.gensalt());
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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":[]}]}
|
||||
{
|
||||
"unicast_port": 8000,
|
||||
"multicast_ip": "224.66.66.1",
|
||||
"multicast_port": 15502,
|
||||
"network_interface": "lo",
|
||||
"tls": true,
|
||||
"storagePath": "D:\\ffe",
|
||||
"users": []
|
||||
}
|
Loading…
Reference in New Issue
Block a user