Aniadido cifrado
This commit is contained in:
		
							parent
							
								
									bd2d28cc04
								
							
						
					
					
						commit
						19e137e5ba
					
				| @ -5,5 +5,6 @@ | |||||||
| 	<classpathentry kind="lib" path="gson-2.8.6-javadoc.jar"/> | 	<classpathentry kind="lib" path="gson-2.8.6-javadoc.jar"/> | ||||||
| 	<classpathentry kind="lib" path="gson-2.8.6-sources.jar"/> | 	<classpathentry kind="lib" path="gson-2.8.6-sources.jar"/> | ||||||
| 	<classpathentry kind="lib" path="gson-2.8.6.jar"/> | 	<classpathentry kind="lib" path="gson-2.8.6.jar"/> | ||||||
|  | 	<classpathentry kind="lib" path="cifrado.jar"/> | ||||||
| 	<classpathentry kind="output" path="bin"/> | 	<classpathentry kind="output" path="bin"/> | ||||||
| </classpath> | </classpath> | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								cifrado.jar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								cifrado.jar
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @ -9,7 +9,7 @@ import java.util.Scanner; | |||||||
| import com.google.gson.Gson; | import com.google.gson.Gson; | ||||||
| 
 | 
 | ||||||
| public class Main { | public class Main { | ||||||
| 
 | 	static String pass="soy segura"; | ||||||
| 	public static void main(String[] args) { | 	public static void main(String[] args) { | ||||||
| 		System.out.println("Entra cliente"); | 		System.out.println("Entra cliente"); | ||||||
| 		Socket socket; | 		Socket socket; | ||||||
| @ -24,13 +24,13 @@ public class Main { | |||||||
| 			Scanner es = new Scanner(System.in); | 			Scanner es = new Scanner(System.in); | ||||||
| 			BufferedReader bufferEntrada = new BufferedReader(new InputStreamReader(socket.getInputStream())); | 			BufferedReader bufferEntrada = new BufferedReader(new InputStreamReader(socket.getInputStream())); | ||||||
| 			PrintWriter bufferSalida = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true); | 			PrintWriter bufferSalida = new PrintWriter(new OutputStreamWriter(socket.getOutputStream()),true); | ||||||
| 			String entrada = gson.fromJson(bufferEntrada.readLine(), String.class); | 			String entrada = gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class); | ||||||
| 			System.out.println(entrada); | 			System.out.println(entrada); | ||||||
| 			 | 			 | ||||||
| 			System.out.println("Introduce el numero de partida en el que quieres entrar"); | 			System.out.println("Introduce el numero de partida en el que quieres entrar"); | ||||||
| 			bufferSalida.println(es.nextLine()); | 			bufferSalida.println(Cifrado.cifrar(gson.toJson(es.nextLine()), pass)); | ||||||
| 			System.out.println(gson.fromJson(bufferEntrada.readLine(), String.class)); | 			System.out.println(gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class)); | ||||||
| 			String tipoJuego = gson.fromJson(bufferEntrada.readLine(), String.class); | 			String tipoJuego = gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class); | ||||||
| 			switch(tipoJuego) { | 			switch(tipoJuego) { | ||||||
| 			case "3": | 			case "3": | ||||||
| 				partida3(bufferEntrada, bufferSalida, es); | 				partida3(bufferEntrada, bufferSalida, es); | ||||||
| @ -47,29 +47,30 @@ public class Main { | |||||||
| 	 | 	 | ||||||
| 	static void partida3(BufferedReader bufferEntrada, PrintWriter bufferSalida, Scanner es) throws IOException { | 	static void partida3(BufferedReader bufferEntrada, PrintWriter bufferSalida, Scanner es) throws IOException { | ||||||
| 		Gson gson = new Gson(); | 		Gson gson = new Gson(); | ||||||
| 		System.out.println(gson.fromJson(bufferEntrada.readLine(), String.class)); | 		System.out.println(gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class)); | ||||||
| 		System.out.println(gson.fromJson(bufferEntrada.readLine(), String.class)); | 		System.out.println(gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class)); | ||||||
| 		while(dibujarTablero(bufferEntrada)) { | 		while(dibujarTablero(bufferEntrada)) { | ||||||
| 			System.out.println("introduce la x de la nueva marca"); | 			System.out.println("introduce la x de la nueva marca"); | ||||||
| 			bufferSalida.println(es.nextLine()); | 			bufferSalida.println(Cifrado.cifrar(gson.toJson(es.nextLine()), pass)); | ||||||
| 			System.out.println("introduce la y de la nueva marca"); | 			System.out.println("introduce la y de la nueva marca"); | ||||||
| 			bufferSalida.println(es.nextLine()); | 			bufferSalida.println(Cifrado.cifrar(gson.toJson(es.nextLine()), pass)); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static void partida4(BufferedReader bufferEntrada, PrintWriter bufferSalida, Scanner es) throws IOException { | 	static void partida4(BufferedReader bufferEntrada, PrintWriter bufferSalida, Scanner es) throws IOException { | ||||||
| 		Gson gson = new Gson(); | 		Gson gson = new Gson(); | ||||||
| 		System.out.println(gson.fromJson(bufferEntrada.readLine(), String.class)); | 		System.out.println(gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class)); | ||||||
| 		System.out.println(gson.fromJson(bufferEntrada.readLine(), String.class)); | 		System.out.println(gson.fromJson(Cifrado.desencriptar(bufferEntrada.readLine(), pass), String.class)); | ||||||
| 		while(dibujarTablero(bufferEntrada)) { | 		while(dibujarTablero(bufferEntrada)) { | ||||||
| 			System.out.println("introduce la columna de la nueva ficha"); | 			System.out.println("introduce la columna de la nueva ficha"); | ||||||
| 			bufferSalida.println(gson.fromJson(es.nextLine(), String.class)); | 			bufferSalida.println(Cifrado.cifrar(gson.toJson(es.nextLine()), pass)); | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	static boolean dibujarTablero(BufferedReader entrada) throws IOException { | 	static boolean dibujarTablero(BufferedReader entrada) throws IOException { | ||||||
| 		Gson gson = new Gson(); | 		Gson gson = new Gson(); | ||||||
| 		String linea = gson.fromJson(entrada.readLine(), String.class); | 		String salida = Cifrado.desencriptar(entrada.readLine(), pass); | ||||||
|  | 		String linea = gson.fromJson(salida, String.class); | ||||||
| 		if(linea.contains("v")) { | 		if(linea.contains("v")) { | ||||||
| 			System.out.println("Has ganado!"); | 			System.out.println("Has ganado!"); | ||||||
| 		}else if (linea.contains("f")){ | 		}else if (linea.contains("f")){ | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user