Java String Encrypt encryptString(final String cadena)

Here you can find the source of encryptString(final String cadena)

Description

Encriptar cadena.

License

Open Source License

Parameter

Parameter Description
cadena the cadena

Return

the string

Declaration

public static String encryptString(final String cadena) 

Method Source Code

//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;
    }
}

Related

  1. encryptIfNotEncrypted(String s)
  2. encryption(String str, int k)
  3. encryptPlayerChat(byte[] is, int i_25_, int i_26_, int i_27_, byte[] is_28_)
  4. encryptPwd(String src)
  5. encryptStrBuff(byte[] resultBytes)
  6. encryptString(String str)
  7. encryptString(String str)
  8. encryptURID(long registrationId)
  9. encryptURL(String url)