Here you can find the source of encryptString(final String cadena)
Parameter | Description |
---|---|
cadena | the cadena |
public static String encryptString(final String cadena)
//package com.java2s; public class Main { /** The patron busqueda. */ private static String searchPattern = "9f0AwB7J8CpDud5E6FQGlxnHMbcI3K4LeUNzO1ms2PtRvSVkWXqirTYaghZjoy"; /** The patron encripta. */ private static String encryptPattern = "wxBU7nIGj9Flm8f0AH1bcK3hdi4WJ5ZLCpDeMvTQuVkXqraYE6gosyNzOP2RSt"; /**/* w w w. j ava 2s . c o m*/ * Encriptar cadena. * * @param cadena * the cadena * @return the string */ public static String encryptString(final String cadena) { String resultado = ""; for (int pos = 0; pos < cadena.length(); pos++) { if (pos == 0) { resultado = encryptChar(cadena.substring(pos, pos + 1), cadena.length(), pos); } else { resultado += encryptChar(cadena.substring(pos, pos + 1), cadena.length(), pos); } } return resultado; } /** * Encriptar caracter. * * @param caracter * the caracter * @param variable * the variable * @param indice * the indice * @return the string */ private static String encryptChar(String caracter, int variable, int indice) { int ind; if (searchPattern.indexOf(caracter) != -1) { ind = (searchPattern.indexOf(caracter) + variable + indice) % searchPattern.length(); return encryptPattern.substring(ind, ind + 1); } return caracter; } }