/*
Sysepub 0.8 - A Symmetric Semi-Public key cipher
Copyright (C) 2002 Pierre Blanc
Pierre Blanc: blanc_teutoburgo@yahoo.it
http://it.geocities.com/teutoburgo
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or go to http://www.gnu.org/copyleft/gpl.html
*/
import java.io.IOException;
/**
* Class Syxor - The XOR used by Sysepub
* Creation date: (30/08/2002 13.12.05)
* @author: Pierre Blanc
*/
public class Syxor {
/**
* Syxor constructor comment.
*/
public Syxor() {
super();
}
public byte[] decrypt(byte[] encrypted, byte[] key) {
int i=0;
int length= encrypted.length;
int keyLength=key.length;
byte[] message = new byte[length];
for (i = 0; i < length && i<keyLength ; i++) {
message[i]=(byte)(encrypted[i]^key[i]);
}
return message;
}
public byte[] encrypt(byte[] message, byte[] key) {
int length=message.length;
byte[] encrypted = new byte[length];
for (int i = 0; i < length && i<key.length; i++) {
encrypted[i]=(byte)(message[i]^key[i]);
}
return encrypted;
}
public static void main
(String args
[]){
/* Syxor s= new Syxor();
byte[] x = new byte[10];
byte[] mng = new byte[10];
for (int i = 0; i < 10; i++) {
x[i] = (byte) (i + 70);
mng[i] = (byte) (i + 80);
}
byte [] test=s.encrypt(x, mng);
byte [] testd=s.decrypt(test, mng);
try{
System.out.write(x);
System.out.println();
System.out.write(mng);
System.out.println("result");
System.out.write(test);
System.out.println("result2");
System.out.write(testd);
} catch (IOException ioe){
ioe.printStackTrace();
}
*/
}
}