so I was working on a homework assignment for my CSC420 class. Professor wanted us to use java code to encrypt two string values that the user would enter. I was able to do, no real issue there; the main problem is that the sample output that he gave to us so that we would know if we got the "right answer" is somehow different then mine. I have attached my code below, my output, and his output; if someone could tell me what I am doing wrong, that would be greatly appreciated.
package Homework;
import static java.nio.charset.StandardCharsets.UTF_8;
import java.util.Base64;
import java.util.Base64.Encoder;
import java.util.Scanner;
public class HW4 {
public static String b64enc(String string) throws Exception {
Encoder encoder = Base64.getEncoder();
byte[] data = string.getBytes(UTF_8);
String encodedString = encoder.encodeToString(data);
return encodedString;
}
public static void main (String [] args) throws Exception {
Scanner scan1 = new Scanner(System.in);
System.out.println("Please enter the first String: ");
String string1 = scan1.nextLine();
System.out.println("Please enter the second string: ");
String string2= scan1.nextLine();
scan1.close();
String encodedString = b64enc(string1 + string2);
System.out.println(encodedString);
}
}
]1

hellohias a direct input using your code and it works fine. I then added theScannerinput and that works fine as well. I'm wondering if it might be an encoding issue at the OS level