package br.com.dougpinheiro.security.hash;
import java.io.IOException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.jboss.security.Base64Encoder;
public class HashFactory {
public static String hash(byte[] data_in){
String string_out = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
string_out = Base64Encoder.encode(md.digest(data_in));
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return string_out;
}
public static void main(String[] args) {
HashFactory hf = new HashFactory();
System.out.println(hf.hash("Fulano".getBytes()));
}
}
Abraço!
Douglas Pinheiro
Nenhum comentário:
Postar um comentário