private byte[] decode(String encodedPassword) { return Hex.decode(encodedPassword); }
@Override public boolean isPlain(String s) { if(null == s || s.isEmpty()) { return true; } for(char c : s.toCharArray()) { if(!Hex.isHexCharacter(c)) { return true; } } return false; }
/** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data Data to digest * @return MD5 digest as a hex string */ public static String md5Hex(String data) { return Hex.encode(md5(data)); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data Data to digest * @return SHA-1 digest as a hex string */ public static String shaHex(byte[] data) { return Hex.encode(sha(data)); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data Data to digest * @return SHA-1 digest as a hex string */ public static String shaHex(String data) { return Hex.encode(sha(data)); }
private void processLiteralCharacters() { if (literalCharactersBuffer.length() > 0) { literalCharacters += literalCharactersBuffer.length(); String s = encodeLiteralCharacters(literalCharactersBuffer.toString()); normalizedTemplate.append(s); // Escape if reserved regex character for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (RESERVED_REGEX_CHARACTERS.contains(c)) { regex.append("\\"); regex.append(c); } else if (c == '%') { final char c1 = s.charAt(i + 1); final char c2 = s.charAt(i + 2); if (Hex.isHexCharacter(c1) && Hex.isHexCharacter(c2)) { regex.append("%").append(HEX_TO_UPPERCASE_REGEX[c1]).append(HEX_TO_UPPERCASE_REGEX[c2]); i += 2; } } else { regex.append(c); } } literalCharactersBuffer.setLength(0); } }
/** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data Data to digest * @return MD5 digest as a hex string */ public static String md5Hex(byte[] data) { return Hex.encode(md5(data)); }
/** * Calculates the MD5 digest and returns the value as a 32 character hex string. * * @param data Data to digest * @return MD5 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String md5Hex(InputStream data) throws IOException { return Hex.encode(md5(data)); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data Data to digest * @return SHA-1 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String shaHex(InputStream data) throws IOException { return Hex.encode(sha(data)); }
/** * Calculates the SHA-256 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-256 digest as a hex string * @since 1.4 */ public static String sha256Hex(byte[] data) { return Hex.encode(sha256(data)); }
/** * Calculates the SHA-256 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-256 digest as a hex string * @since 1.4 */ public static String sha256Hex(String data) { return Hex.encode(sha256(data)); }
/** * Calculates the SHA-512 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-512 digest as a hex string * @since 1.4 */ public static String sha512Hex(byte[] data) { return Hex.encode(sha512(data)); }
private String encode(String rawPassword, byte[] salt) { byte[] digest = digest(rawPassword, salt); return new String(Hex.encode(digest)); }
/** * Calculates the SHA-384 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-384 digest as a hex string * @since 1.4 */ public static String sha384Hex(byte[] data) { return Hex.encode(sha384(data)); }
/** * Calculates the SHA-384 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-384 digest as a hex string * @since 1.4 */ public static String sha384Hex(String data) { return Hex.encode(sha384(data)); }
/** * Calculates the SHA-512 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-512 digest as a hex string * @since 1.4 */ public static String sha512Hex(String data) { return Hex.encode(sha512(data)); }
/** * Calculates the SHA-512 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-512 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String sha512Hex(InputStream data) throws IOException { return Hex.encode(sha512(data)); }
/** * Calculates the SHA-384 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-384 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String sha384Hex(InputStream data) throws IOException { return Hex.encode(sha384(data)); }
public static String hexHmac256(byte[] secret, String data) { return Hex.encode(hmac256(secret, data)); }
/** * Calculates the SHA-256 digest and returns the value as a hex string. * <p> * Throws a <code>RuntimeException</code> on JRE versions prior to 1.4.0. * </p> * * @param data Data to digest * @return SHA-256 digest as a hex string * @throws IOException On error reading from the stream * @since 1.4 */ public static String sha256Hex(InputStream data) throws IOException { return Hex.encode(sha256(data)); }