Minor changes

This commit is contained in:
Laurent
2025-10-24 15:13:18 +02:00
parent eb11b9da05
commit e967383845

View File

@@ -9,11 +9,13 @@ import java.io.*;
import java.net.*;
import java.nio.charset.StandardCharsets;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
import java.security.SecureRandom;
import java.util.Base64;
public class Main {
private static final String PROVIDER = "SunJCE";
private static final String ALGORITHM = "DESede";
private static final String TRANSFORMATION = "DESede/ECB/PKCS5Padding";
@@ -65,9 +67,9 @@ public class Main {
}
}
public static void send(Socket socket, String message) throws IOException {
public static void send(Socket socket, String data) throws IOException {
OutputStream output = socket.getOutputStream();
output.write(String.format("%s\r\n", message).getBytes(StandardCharsets.UTF_8));
output.write(String.format("%s\r\n", data).getBytes(StandardCharsets.UTF_8));
output.flush();
}
@@ -75,9 +77,9 @@ public class Main {
return reader.readLine();
}
public static SecretKey get3DESKey() throws NoSuchAlgorithmException {
KeyGenerator keyGen = KeyGenerator.getInstance(ALGORITHM);
keyGen.init(168);
public static SecretKey get3DESKey() throws NoSuchAlgorithmException, NoSuchProviderException {
KeyGenerator keyGen = KeyGenerator.getInstance(ALGORITHM, PROVIDER);
keyGen.init(new SecureRandom());
return keyGen.generateKey();
}