Java - Encriptacion

 
Vista:

Encriptacion

Publicado por Brandon (1 intervención) el 04/03/2017 21:52:47
Hola necesito ayuda de urg lo que pasa es que tengo esta clase con el metodo hash el cual encripta la información, necesito crear un metodo el cual desencripte la información del archivo encriptado por este metodo.
adjunto la clase para que puedan verificar
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
 
public class AESencriptar {
	//Metodo para encriptar 
	 public static String hash(String input){
	    try
	    {
	      MessageDigest digest = MessageDigest.getInstance("SHA-256");
	      byte[] hash = (input + "4582ATAZ77Pert").getBytes("UTF-8");
 
	      for (int i = 0; i < 10; i++) {
 
	        hash = digest.digest(hash);
	      }
	      StringBuilder hexString = new StringBuilder();
	      for (int i = 0; i < hash.length; i++)
	      {
	        String hex = Integer.toHexString(0xFF & hash[i]);
	        if (hex.length() == 1) {
	          hexString.append('0');
	        }
	        hexString.append(hex);
	      }
	      return hexString.toString();
	    }
	    catch (NoSuchAlgorithmException|UnsupportedEncodingException ex) {}
	    return null;
	  }
//Ejecutable metodo main
	public static void main(String[] args) {
		String texto="GONZALEZ123";
		AESencriptar encrip=new AESencriptar();
		System.out.println("Texto encriptado:  "+ encrip.hash(texto));
 
	}
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder