Below I share an snippet of code in Java language, which can generate with just 3 lines of code, a text using cryptographic hash functions SHA1 (Secure Hash Algorithm, Secure Hash Algorithm version 2)
public static String generate (String input) throws Exception {
MessageDigest md = MessageDigest.getInstance ("SHA1");
byte [] = md.digest digested (input.getBytes ());
return new BigInteger (1, digested) .toString (16);
}
To use MD5, just change the string "SHA1" with "MD5"
more info:
SHA, Wikipedia
Standard Algorithm Name Documentation
No hay comentarios:
Publicar un comentario