I want to change data from input by Reformat

Hi,
1. I want to change data from in put such as filed A value = JAPAN COUNTRY to be any things value that is not same as input when transform to output, what is function I can use it, please give me an example.
2. I want to encrypt data from input to output, what function I can use and please give an example.

Thank you

Hi Jean,

Could you please rephrase your question nr. 1? I am not sure what is your goal here.

Regarding your second question, we do not have support for encryption like e.g. RSA in our CTL language. However, we have secure (encrypted) parameters, see http://doc.cloveretl.com/documentation/ … eters.html

We have digestion functions SHA and MD5, encoding functions like base64, support for secure protocols like HTTPS and you can of course create your own transformation in Java using some external library allowing you to use RSA.

Kind regards,

Hi,

For nr.1 I mean I would like to masking data from input. Such as Mr.Jason will be XXXAVSB something like this.
I would like to know, can I use reformat to do masking or hashing data?

Thank you.

I think this can be achieved by the aforesaid functions. Hashing functions available in CTL are MD5, SHA-1 and SHA-256. Encoding function is base64. Are these functions suitable for your task?

Kind regards,

If I would like to masking Field2, how do I write clt please advice.

Thank you.

Hi Jean,

sha function returns byte data type, but your output field is string. So you need to convert it. You have at least 3 options:

* use byte2base64 function (converts bytes to base64)
* use byte2hex function (converts bytes to hexadecimal notation)
* use byte2str function (converts bytes into string; please note that output will be string where some characters are not printable)

Documentation for all 3 functions is available here: http://doc.cloveretl.com/documentation/ … -ctl2.html

I hope this helps.

Hi Jean,

I guess following CTL functions could solve your problem:

string replace(string arg, string regex, string replacement);

The replace(string, string, string) function takes three string arguments - a string, a regular expression, and a replacement - and replaces all regex matches inside the string with the specified replacement string. All parts of the string that match the regex are replaced. The user can also reference the matched text using a backreference in the replacement string. A backreference to the entire match is indicated as $0. If there are capturing parentheses, specifics groups as $1, $2, $3, etc can be referenced.

replace("Hello","[Ll]","t") returns "Hetto"

replace("Hello", "e(l+)", "a$1") returns "Hallo"

Important - please beware of similar syntax of $0, $1 etc. While used inside the replacement string it refers to matching regular expression parenthesis (in order). If used outside a string, it means a reference to an input field. See other example:

replace("Hello", "e(l+)", $0.name) returns HJohno if input field "name" on port 0 contains the name "John".

A modifier cen be used at the start of the regular expression: (?i) for case-insensitive search, (?m) for multiline mode or (?s) for “dotall” mode where a dot (“.”) matches even a newline character

replace("Hello", "(?i)L", "t") will produce Hetto while replace("Hello", "L", "t") will just produce Hello

If the first argument of the function is null, the function returns null. If the regexp pattern is null, the function fails with error. If the third argument is null, the function fails with error, unless the specified regexp doesn’t match the first input.

string translate(string arg, string searchingSet, string replaceSet);

The translate(string, string, string) function replaces the characters given in the second string of the first argument with characters from the third string. Thus the function call

translate('Hello','eo','iy') results in the string Hilly.
translate($0.name,'abcde',edcba') results in the source string/field with reversed letters a->e , b->d, c->c, d->b, e->a.

If one or both of the second or the third argument is null, the function fails with error.

If the input of the function is null, the function returns null.

All string manipulation functions are available in CloverETL’s manual.