Compare commits

...

2 commits

Author SHA1 Message Date
fb459defea
add byte arrays to TypesStreams 2024-06-09 22:01:40 +02:00
f3508cb27f
make keys more secure 2024-06-09 17:01:33 +02:00
4 changed files with 31 additions and 10 deletions

View file

@ -39,14 +39,6 @@ javadoc {
new URL("https://raw.githubusercontent.com/TudbuT/tools/master/dark_javadoc.css").newInputStream().
readLines().join("\n").getBytes()
); f.close()
}
}
jar {
doLast {
File jar = new File("build/libs/tuddylib.jar")
File loc = new File("TuddyLIB.jar")
jar.renameTo(loc)
ZipOutputStream out = new ZipOutputStream(new FileOutputStream("TuddyLIB-javadoc.zip"))
new File("build/docs/javadoc").eachFileRecurse(groovy.io.FileType.FILES) {
@ -60,6 +52,14 @@ jar {
}
}
jar {
doLast {
File jar = new File("build/libs/tuddylib.jar")
File loc = new File("TuddyLIB.jar")
jar.renameTo(loc)
}
}
//jar.dependsOn("javadoc")
publishing {

View file

@ -115,6 +115,18 @@ public class TypedInputStream {
}
return booleans;
}
public byte[] readByteArray() throws IOException {
byte[] bytes = new byte[readInt()];
int n = 0;
while ((n += stream.read(bytes, n, bytes.length - n)) != 0);
if(n != bytes.length) {
byte[] cutBytes = new byte[n];
System.arraycopy(bytes, 0, cutBytes, 0, n);
return cutBytes;
}
return bytes;
}
public String readString() throws IOException {
int i = readInt();

View file

@ -118,6 +118,13 @@ public class TypedOutputStream {
stream.flush();
return booleans;
}
public byte[] writeByteArray(byte[] bytes) throws IOException {
int i = bytes.length;
writeInt(i);
stream.write(bytes);
return bytes;
}
public String writeString(String string) throws IOException {
int i = string.length();

View file

@ -5,6 +5,8 @@ import de.tudbut.tools.Hasher;
import de.tudbut.tools.ObjectSerializerTCN;
import de.tudbut.tools.Tools;
import java.nio.charset.StandardCharsets;
import java.security.SecureRandom;
import java.util.Objects;
/**
@ -18,7 +20,7 @@ public class Key implements Cloneable {
* Generates a random Key
*/
public Key() {
string = Tools.randomAlphanumericString(1024);
this(SecureRandom.getSeed(1024));
}
/**
@ -34,7 +36,7 @@ public class Key implements Cloneable {
* @param bytes Key as byte[]
*/
public Key(byte[] bytes) {
string = new String(bytes);
string = new String(bytes, StandardCharsets.ISO_8859_1);
}
/**