Creating a routine - 7.1

Talend Data Management Platform Studio User Guide

Version
7.1
Language
English (United States)
Product
Talend Data Management Platform
Module
Talend Studio
Content
Design and Development

In this procedure, create a custom routine to execute the algorithm for password encryption.

Procedure

  1. In the Repository tree view of your Talend Studio, expand the Code node, right-click Routines and select Create routine from the contextual menu to create a new routine named MyRoutine.
  2. In the new routine that opened in the routine editor, add a function named decrypt and define the specify mechanism to decrypt the encryption string of the password.
    The code of the function reads as follows:
    public class MyRoutine {
        public static String decrypt(String encryptedPassword) {
            StringBuffer output = new StringBuffer();
            for (int i = 0; i < encryptedPassword.length(); i++) {
                char c = encryptedPassword.charAt(i);
                if (c >= 'a' && c <= 'm')
                    c += 13;
                else if (c >= 'A' && c <= 'M')
                    c += 13;
                else if (c >= 'n' && c <= 'z')
                    c -= 13;
                else if (c >= 'N' && c <= 'Z')
                    c -= 13;
                output.append(c);
            }
            return output.toString();
        }
    }
  3. When done, click Ctrl+S to save your routine.