Android Password Descrypt decryptionKey(String password)

Here you can find the source of decryptionKey(String password)

Description

decryption Key

Declaration

public static String decryptionKey(String password) 

Method Source Code

//package com.java2s;

public class Main {
    private static String key2 = "1234567890-";
    private static String key1 = "13245";

    public static String decryptionKey(String password) {
        byte[] keyByte1 = key1.getBytes();
        byte[] keyByte2 = key2.getBytes();
        //password = hexStr2Str(password);
        byte[] pwdByte = hexStr2Bytes(password);

        for (int i = 0; i < pwdByte.length; i++) {
            pwdByte[i] = (byte) (pwdByte[i] ^ keyByte2[i % keyByte2.length]);
        }//from  w ww  . j av  a 2s .c  o m

        byte[] lastByte = new byte[pwdByte.length - keyByte1.length];
        for (int i = 0; i < lastByte.length; i++) {
            lastByte[i] = pwdByte[i];
        }
        for (int i = 0; i < lastByte.length; i++) {
            lastByte[i] = (byte) (lastByte[i] ^ keyByte1[i
                    % keyByte1.length]);
        }

        return new String(lastByte);
    }

    public static byte[] hexStr2Bytes(String src) {
        int m = 0, n = 0;
        int l = src.length() / 2;
        byte[] ret = new byte[l];
        for (int i = 0; i < l; i++) {
            m = i * 2 + 1;
            n = m + 1;
            ret[i] = Byte.decode("0x" + src.substring(i * 2, m)
                    + src.substring(m, n));
        }
        return ret;
    }
}

Related

  1. decryptionKey(String password)
  2. decrypt(String password, String encryptedData)