Java Code Examples for org.apache.flink.table.utils.EncodingUtils#hex()

The following examples show how to use org.apache.flink.table.utils.EncodingUtils#hex() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SqlFunctionUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Calculate the hash value of a given string.
 *
 * @param algorithm    message digest algorithm.
 * @param str          string to hash.
 * @param charsetName  charset of string.
 * @return           hash value of string.
 */
public static String hash(String algorithm, String str, String charsetName) {
	try {
		byte[] digest = MessageDigest
			.getInstance(algorithm)
			.digest(strToBytesWithCharset(str, charsetName));
		return EncodingUtils.hex(digest);
	} catch (NoSuchAlgorithmException e) {
		throw new IllegalArgumentException("Unsupported algorithm: " + algorithm, e);
	}
}
 
Example 2
Source File: SqlFunctionUtils.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Calculate the hash value of a given string.
 *
 * @param algorithm    message digest algorithm.
 * @param str          string to hash.
 * @param charsetName  charset of string.
 * @return           hash value of string.
 */
public static String hash(String algorithm, String str, String charsetName) {
	try {
		byte[] digest = MessageDigest
			.getInstance(algorithm)
			.digest(strToBytesWithCharset(str, charsetName));
		return EncodingUtils.hex(digest);
	} catch (NoSuchAlgorithmException e) {
		throw new IllegalArgumentException("Unsupported algorithm: " + algorithm, e);
	}
}
 
Example 3
Source File: UserDefinedFunction.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a unique, serialized representation for this function.
 */
public final String functionIdentifier() {
	final String md5 = EncodingUtils.hex(EncodingUtils.md5(EncodingUtils.encodeObjectToString(this)));
	return getClass().getCanonicalName().replace('.', '$').concat("$").concat(md5);
}
 
Example 4
Source File: UserDefinedFunction.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a unique, serialized representation for this function.
 */
public final String functionIdentifier() {
	final String md5 = EncodingUtils.hex(EncodingUtils.md5(EncodingUtils.encodeObjectToString(this)));
	return getClass().getCanonicalName().replace('.', '$').concat("$").concat(md5);
}
 
Example 5
Source File: StringFunctions.java    From Alink with Apache License 2.0 4 votes vote down vote up
public static String hash(String str, MessageDigest md) {
    return EncodingUtils.hex(md.digest(str.getBytes(StandardCharsets.UTF_8)));
}
 
Example 6
Source File: UserDefinedFunction.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a unique, serialized representation for this function.
 */
public final String functionIdentifier() {
	final String md5 = EncodingUtils.hex(EncodingUtils.md5(EncodingUtils.encodeObjectToString(this)));
	return getClass().getName().replace('.', '$').concat("$").concat(md5);
}