Android String Decrypt decrypt(String old)

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

Description

decrypt

Declaration

public static String decrypt(String old) 

Method Source Code

//package com.java2s;
import java.io.UnsupportedEncodingException;

public class Main {

    public static String decrypt(String old) {
        String key = "a12348a9gde";
        if (old == null || old.equals("")) {
            return "";
        }//from  www  .ja  va  2s  .c o m
        String newStr = null;
        try {
            byte[] keyData = key.getBytes("UTF-8");
            byte[] strData = new byte[old.length() / 2];
            int i = 0;
            for (int x = 0; x < old.length(); x = x + 2) {
                String s = old.substring(x, x + 2);
                int a = Integer.parseInt(s, 16);
                byte b = (byte) (a ^ keyData[i++ % keyData.length]);
                strData[x / 2] = b;
            }
            newStr = new String(strData, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            newStr = "";
        } catch (Exception e) {
            newStr = "";
        }
        return newStr;
    }
}

Related

  1. decrypt(String keyStr, String encryptData)
  2. decrypt(String seed, String encrypted)