Added Parity/Sanity to Scrambling

This commit is contained in:
Sn0wStorm
2019-10-11 18:05:49 +02:00
parent 9bf3268fb4
commit 2121bf5c8a
4 changed files with 15 additions and 5 deletions
@@ -3,6 +3,7 @@ package com.dre.brewery.lore;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
public class XORUnscrambleStream extends FilterInputStream {
@@ -17,7 +18,7 @@ public class XORUnscrambleStream extends FilterInputStream {
this.seed = seed;
}
public void start() throws IOException {
public void start() throws IOException, InvalidKeyException {
running = true;
if (xorStream == null) {
short id = (short) (in.read() << 8 | in.read());
@@ -26,6 +27,9 @@ public class XORUnscrambleStream extends FilterInputStream {
return;
}
xorStream = new SeedInputStream(seed ^ id);
if (read() != 209) { // Parity/Sanity
throw new InvalidKeyException("Could not read scrambled data, is the seed wrong?");
}
}
}