Created
October 21, 2010 05:01
-
-
Save eos87/637971 to your computer and use it in GitHub Desktop.
md5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* To change this template, choose Tools | Templates | |
* and open the template in the editor. | |
*/ | |
package utils; | |
import java.security.MessageDigest; | |
import java.security.NoSuchAlgorithmException; | |
import java.util.logging.*; | |
/** | |
* | |
* @author e0s87 | |
*/ | |
public class Codificador { | |
/** * Clase con métodos estáticos de cifrado * */ | |
public String getEncoded(String texto, String algoritmo) { | |
String output=""; | |
try { | |
byte[] textBytes = texto.getBytes(); | |
MessageDigest md = MessageDigest.getInstance(algoritmo); | |
md.update(textBytes); | |
byte[] codigo = md.digest(); | |
output = new String(codigo); | |
} catch (NoSuchAlgorithmException ex) { | |
Logger.getLogger(Codificador.class.getName()).log(Level.SEVERE, null, ex); | |
} | |
return output; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment