Java String Descrypt decrypt(String src)

Here you can find the source of decrypt(String src)

Description

decrypt

License

Open Source License

Parameter

Parameter Description
src a parameter

Declaration

public static String decrypt(String src) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//from w w w .  j  a v a2  s .  co m
     * decrypt
     * 
     * @param src
     * @return
     */
    public static String decrypt(String src) {
        String ecrt = "";
        for (int i = 0; i < src.length(); i++) {
            char a = src.charAt(i);
            if (a == '#') {
                ecrt += "0";
            } else if (a == '&') {
                ecrt += "1";
            } else if (a == '2') {
                ecrt += "2";
            } else if (a == '@') {
                ecrt += "3";
            } else if (a == 'W') {
                ecrt += "4";
            } else if (a == '!') {
                ecrt += "5";
            } else if (a == '~') {
                ecrt += "6";
            } else if (a == '*') {
                ecrt += "7";
            } else if (a == ')') {
                ecrt += "8";
            } else if (a == '_') {
                ecrt += "9";
            } else if (a == 'V') {
                ecrt += "A";
            } else if (a == 'Y') {
                ecrt += "B";
            } else if (a == '^') {
                ecrt += "C";
            } else if (a == '+') {
                ecrt += "D";
            } else if (a == '%') {
                ecrt += "E";
            } else if (a == '(') {
                ecrt += "F";
            }
        }
        String dcode = decode(ecrt);
        return dcode;
    }

    public static String decode(String s) {
        byte[] baKeyword = new byte[s.length() / 2];
        for (int i = 0; i < baKeyword.length; i++) {
            try {
                baKeyword[i] = (byte) (0xff & Integer.parseInt(s.substring(i * 2, (i * 2) + 2), 16));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

        try {
            s = new String(baKeyword, "GB2312");// UTF-16le:Not
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return s;
    }
}

Related

  1. decrypt(String data, String key)
  2. decrypt(String inString)
  3. decrypt(String s)
  4. decrypt(String s)
  5. decrypt(String s, int offset)
  6. decrypt(String str)
  7. Decrypt(String str)
  8. decrypt(String str)
  9. decrypt(String str)