Skip to content

Instantly share code, notes, and snippets.

@joaomosantos
Created August 27, 2015 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joaomosantos/ce7cb50475e34680d000 to your computer and use it in GitHub Desktop.
Save joaomosantos/ce7cb50475e34680d000 to your computer and use it in GitHub Desktop.
Java - Criptografia
import java.math.BigInteger;
import java.security.*;
public static void main(String[] args) {
String texto = "admin";
Criptografar(texto);
}
public static void Criptografar(String str) {
try {
MessageDigest m = MessageDigest.getInstance("MD5");
m.update(str.getBytes(), 0, str.length());
String senha = new BigInteger(1, m.digest()).toString(16);
System.out.println("Senha: " + senha);
} catch (Exception ex) {
System.out.println("Erro ao Criptografar");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment