1 //Copyright (C) 2004, Brian Enigma <enigma at netninja.com> 2 //This file is part of MagicCodes. 3 // 4 //MagicCodes is free software; you can redistribute it and/or modify 5 //it under the terms of the GNU General Public License as published by 6 //the Free Software Foundation; either version 2 of the License, or 7 //(at your option) any later version. 8 // 9 //MagicCodes is distributed in the hope that it will be useful, 10 //but WITHOUT ANY WARRANTY; without even the implied warranty of 11 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 //GNU General Public License for more details. 13 // 14 //You should have received a copy of the GNU General Public License 15 //along with Foobar; if not, write to the Free Software 16 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 package org.ninjasoft.magiccodes.plugins; 18 19 /*** 20 * Plugin to compute simple XOR values 21 * @author enigma 22 */ 23 public class Xor implements Plugin { 24 public String getName() { 25 return "XOR"; 26 } 27 public String getDescription() { 28 return "A plugin to calculate XOR against a simple key"; 29 } 30 public int[] doAction(int[] in, int[] key) { 31 for (int i=0; i<in.length; i++) { 32 in[i] = in[i] ^ key[i % key.length]; 33 } 34 return in; 35 } 36 public boolean isInformational() { 37 return false; 38 } 39 public boolean usesKey() { 40 return true; 41 } 42 }