Java xor xor(String key, String input)

Here you can find the source of xor(String key, String input)

Description

Simple XOR encryption

License

Apache License

Declaration

public static String xor(String key, String input) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    /**/*from  www  . j a v a 2  s. c  o m*/
     * Simple XOR encryption
     * @see <a href="https://github.com/KyleBanks/XOREncryption/blob/master/Java%20(Android%20compatible)/XOREncryption.java">Sources on GitHub</a>
     */
    public static String xor(String key, String input) {
        StringBuilder output = new StringBuilder();

        for (int i = 0; i < input.length(); i++) {
            output.append((char) (input.charAt(i) ^ key.charAt(i % key.length())));
        }

        return output.toString();
    }
}

Related

  1. xor(int[] byteOne, int[] byteTwo)
  2. xor(int[] byteOne, int[] byteTwo)
  3. xor(int[][] array, int[][] array2)
  4. xor(long x, long y)
  5. xor(short b1, short b2)
  6. xor(T l1, T l2)
  7. xor32(byte[] a, short aOffset, byte[] b, short bOffset, byte[] result, short offset)
  8. xorFolding(final long hash, final int shift)
  9. xorInPlace(byte[] source, int sourceOffset, byte[] destination, int destinationOffset, int size)