Java String Descrypt decrypt(String s)

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

Description

decrypt

License

CDDL license

Declaration

public final static String decrypt(String s) 

Method Source Code

//package com.java2s;
//License from project: CDDL license 

public class Main {
    private final static int Crypt1 = 52895, Crypt2 = 22419;
    private final static int Cryptkey = 23647;

    public final static String decrypt(String s) {
        return decrypt(s, Cryptkey);
    }/*  www .ja va  2  s  .  c om*/

    public static String decrypt(String s, long key) {
        if (s == null || s.length() < 1)
            return null;
        char[] buf = new char[s.length()];
        int buflen = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (ch == '%')
                try {
                    buf[buflen++] = (char) Integer.parseInt(s.substring(i + 1, i + 3), 16);
                    i += 2;
                } catch (NumberFormatException e) {
                    throw new InternalError("decrypt: invalid code");
                }
            else
                buf[buflen++] = ch;
        }
        for (int i = 0; i < buflen; i++) {
            char encr = (char) buf[i];
            char decr = (char) ((encr ^ key) & 0xff);
            key = (long) ((encr + key) * Crypt1 + Crypt2);
            buf[i] = decr;
        }
        return String.valueOf(buf, 0, buflen);
    }
}

Related

  1. decrypt(byte[] serialize)
  2. decrypt(int encrypted, int salt)
  3. decrypt(String arg0)
  4. decrypt(String data, String key)
  5. decrypt(String inString)
  6. decrypt(String s)
  7. decrypt(String s, int offset)
  8. decrypt(String src)
  9. decrypt(String str)