Created
August 27, 2015 19:22
-
-
Save joaomosantos/ce7cb50475e34680d000 to your computer and use it in GitHub Desktop.
Java - Criptografia
This file contains 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
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