class EncryptUtil {

    public static String encrypt(String key, String source) {
        try {
            // Get our secret key
            Key key0 = getKey(key);
            // Create the cipher
            Cipher desCipher = Cipher.getInstance("DES/ECB/PKCS5Padding");
            // Initialize the cipher for encryption
            desCipher.init(Cipher.ENCRYPT_MODE, key0);
            // Our cleartext as bytes
            byte[] cleartext = source.getBytes();
            // Encrypt the cleartext
            byte[] ciphertext = desCipher.doFinal(cleartext);
            // convert to Base64
            //byte[] b64cipherText = Base64.encodeBase64(ciphertext);
            // Return a String representation of the cipher text
            //return StringUtil.getAsciiString(b64cipherText);
            // replaced Jakarta Base64 with custom one
            return Base64Codec.encode(ciphertext);
        } catch (Exception e) {
            throw new RuntimeException(e.getMessage());
        }
    }

}