cache: remove netty-buffer dependency

This commit is contained in:
Adam
2022-01-18 16:58:51 -05:00
parent b3e87ee875
commit b53dc9ee8f
2 changed files with 14 additions and 19 deletions

5
cache/pom.xml vendored
View File

@@ -59,11 +59,6 @@
<groupId>com.google.code.gson</groupId> <groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId> <artifactId>gson</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
<version>4.1.0.Final</version>
</dependency>
<dependency> <dependency>
<groupId>org.antlr</groupId> <groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId> <artifactId>antlr4-runtime</artifactId>

View File

@@ -24,8 +24,8 @@
*/ */
package net.runelite.cache.util; package net.runelite.cache.util;
import io.netty.buffer.ByteBuf; import net.runelite.cache.io.InputStream;
import io.netty.buffer.Unpooled; import net.runelite.cache.io.OutputStream;
public class Xtea public class Xtea
{ {
@@ -42,13 +42,13 @@ public class Xtea
public byte[] encrypt(byte[] data, int len) public byte[] encrypt(byte[] data, int len)
{ {
ByteBuf buf = Unpooled.wrappedBuffer(data, 0, len); InputStream in = new InputStream(data);
ByteBuf out = Unpooled.buffer(len); OutputStream out = new OutputStream(len);
int numBlocks = len / 8; int numBlocks = len / 8;
for (int block = 0; block < numBlocks; ++block) for (int block = 0; block < numBlocks; ++block)
{ {
int v0 = buf.readInt(); int v0 = in.readInt();
int v1 = buf.readInt(); int v1 = in.readInt();
int sum = 0; int sum = 0;
for (int i = 0; i < ROUNDS; ++i) for (int i = 0; i < ROUNDS; ++i)
{ {
@@ -59,19 +59,19 @@ public class Xtea
out.writeInt(v0); out.writeInt(v0);
out.writeInt(v1); out.writeInt(v1);
} }
out.writeBytes(buf); out.writeBytes(in.getRemaining());
return out.array(); return out.flip();
} }
public byte[] decrypt(byte[] data, int len) public byte[] decrypt(byte[] data, int len)
{ {
ByteBuf buf = Unpooled.wrappedBuffer(data, 0, len); InputStream in = new InputStream(data);
ByteBuf out = Unpooled.buffer(len); OutputStream out = new OutputStream(len);
int numBlocks = len / 8; int numBlocks = len / 8;
for (int block = 0; block < numBlocks; ++block) for (int block = 0; block < numBlocks; ++block)
{ {
int v0 = buf.readInt(); int v0 = in.readInt();
int v1 = buf.readInt(); int v1 = in.readInt();
int sum = GOLDEN_RATIO * ROUNDS; int sum = GOLDEN_RATIO * ROUNDS;
for (int i = 0; i < ROUNDS; ++i) for (int i = 0; i < ROUNDS; ++i)
{ {
@@ -82,7 +82,7 @@ public class Xtea
out.writeInt(v0); out.writeInt(v0);
out.writeInt(v1); out.writeInt(v1);
} }
out.writeBytes(buf); out.writeBytes(in.getRemaining());
return out.array(); return out.flip();
} }
} }