Java String XOR Decode xorDecode(String data, String key)

Here you can find the source of xorDecode(String data, String key)

Description

xor Decode

License

Open Source License

Declaration

public static String xorDecode(String data, String key) 

Method Source Code

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

public class Main {
    public static String xorDecode(String data, String key) {
        byte m_cData[] = data.getBytes();
        byte m_cKey[] = key.getBytes();
        int keyPointer = 0;
        byte keyPointerAdd = 0;
        for (int i = 0; i < m_cData.length; i++) {
            keyPointerAdd = m_cData[i];/*  ww w .  ja  v a 2  s . co  m*/
            m_cData[i] ^= m_cKey[keyPointer];
            keyPointer += keyPointerAdd;
            keyPointer %= m_cKey.length;
        }
        return new String(m_cData);
    }
}

Related

  1. XORdecode(String res, String key)