Merge branch 'master' of github.com:jesssystemv/basebandrewrite

This commit is contained in:
Jess 2023-11-16 14:52:42 +00:00
commit 89dbe112bf
4 changed files with 41 additions and 24 deletions

View file

@ -1,6 +1,8 @@
package com.baseband.client;
import de.tudbut.tools.Tools;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
@ -15,7 +17,7 @@ public class Key {
public Key() {
string = getRandomTicket();
string = Tools.randomAlphanumericString(4096);
}
public Key(String key) {
@ -23,20 +25,13 @@ public class Key {
}
public Key(byte[] key) {
string = new String(key);
string = new String(key, StandardCharsets.ISO_8859_1);
}
public void setDebug(boolean debug) {
this.debug = debug;
}
private static String getRandomTicket() {
StringBuilder buffer = new StringBuilder();
for (int count = 0; count < 64; ++count) {
buffer.append(UUID.randomUUID());
}
return buffer.toString();
}
public byte[] serializeObject(Object obj) {

View file

@ -14,11 +14,11 @@ public class Key {
* Generates a random Key
*/
public Key() {
string = getRandomTicket();
string = randomAlphanumericString(4096);
}
public Key(byte[] key) {
string = new String(key);
string = new String(key, StandardCharsets.ISO_8859_1);
}
public Key(String key) {
@ -29,12 +29,23 @@ public class Key {
this.debug = debug;
}
private static String getRandomTicket() {
StringBuilder buffer = new StringBuilder();
for (int count = 0; count < 64; ++count) {
buffer.append(UUID.randomUUID());
public static int random(int lower, int upper) {
return (int) (Math.floor(Math.random() * (upper - lower)) + lower);
}
return buffer.toString();
public static String randomString(int length, String pool) {
StringBuilder r = new StringBuilder();
for (int i = 0; i < length; i++) {
r.append(pool.charAt(random(0, pool.length())));
}
return r.toString();
}
public static String randomAlphanumericString(int length) {
String alphabet = "abcdefghijklmnopqrstuvwxyz";
String pool = alphabet + alphabet.toUpperCase() + "0123456789";
return randomString(length, pool);
}
public byte[] decryptByte(byte[] bytes) {

View file

@ -24,7 +24,7 @@ public class Key {
}
public Key(byte[] key) {
string = new String(key);
string = new String(key, StandardCharsets.ISO_8859_1);
}

View file

@ -15,7 +15,7 @@ public class Key {
* Generates a random Key
*/
public Key() {
string = getRandomTicket();
string = randomAlphanumericString(4096);
}
public Key(String key) {
@ -23,19 +23,30 @@ public class Key {
}
public Key(byte[] keyData) {
string = new String(keyData);
string = new String(keyData, StandardCharsets.ISO_8859_1);
}
public void setDebug(boolean debug) {
this.debug = debug;
}
private static String getRandomTicket() {
StringBuilder buffer = new StringBuilder();
for (int count = 0; count < 64; ++count) {
buffer.append(UUID.randomUUID());
public static int random(int lower, int upper) {
return (int) (Math.floor(Math.random() * (upper - lower)) + lower);
}
return buffer.toString();
public static String randomString(int length, String pool) {
StringBuilder r = new StringBuilder();
for (int i = 0; i < length; i++) {
r.append(pool.charAt(random(0, pool.length())));
}
return r.toString();
}
public static String randomAlphanumericString(int length) {
String alphabet = "abcdefghijklmnopqrstuvwxyz";
String pool = alphabet + alphabet.toUpperCase() + "0123456789";
return randomString(length, pool);
}