Created
August 6, 2014 17:14
-
-
Save dilnei/b5c5b1c526064e68df7c to your computer and use it in GitHub Desktop.
Gera uma String hash, padrão SHA-256, SHA-384, SHA1-HEX.
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
| package br.com.risingforce.geradores; | |
| import org.apache.commons.codec.digest.DigestUtils; | |
| /** | |
| * <b>Classe que gera uma String hash, padrão SHA-256, SHA-384, SHA1-HEX.</b> | |
| * | |
| * @author Dilnei Cunha. | |
| */ | |
| public class HexEncoding { | |
| /** | |
| * <b>Calcula o SHA-256 digest e retorna o valor como uma string | |
| * hexadecimal.</b> | |
| * | |
| * @param str | |
| * @return String | |
| */ | |
| public static String hexaDecimalEncodingSHA256(String str) { | |
| final String hash = DigestUtils.sha256Hex(str); | |
| return hash; | |
| } | |
| /** | |
| * <b>Calcula o SHA-384 digest e retorna o valor como uma string | |
| * hexadecimal.</b> | |
| * | |
| * @param str | |
| * @return String | |
| */ | |
| public static String hexaDecimalEncodingSHA384(String str) { | |
| final String hash = DigestUtils.sha384Hex(str); | |
| return hash; | |
| } | |
| /** | |
| * <b>Calcula o SHA-512 digest e retorna o valor como uma string | |
| * hexadecimal.</b> | |
| * | |
| * @param str | |
| * @return String | |
| */ | |
| public static String hexaDecimalEncodingSHA512(String str) { | |
| final String hash = DigestUtils.sha512Hex(str); | |
| return hash; | |
| } | |
| /** | |
| * <b>Calcula o SHA1-HEX digest e retorna o valor como uma string | |
| * hexadecimal.</b> | |
| * | |
| * @param str | |
| * @return String | |
| */ | |
| public static String hexaDecimalEncodingSHA1Hex(String str) { | |
| final String hash = DigestUtils.sha1Hex(str); | |
| return hash; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment