Java String XOR Encode xorEncode(String data, String key)

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

Description

xor Encode

License

Open Source License

Declaration

public static String xorEncode(String data, String key) 

Method Source Code

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

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

Related

  1. XORencode(String res, String key)