Merge branch 'master' of github.com:jesssystemv/basebandrewrite
This commit is contained in:
commit
89dbe112bf
4 changed files with 41 additions and 24 deletions
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -24,7 +24,7 @@ public class Key {
|
|||
}
|
||||
|
||||
public Key(byte[] key) {
|
||||
string = new String(key);
|
||||
string = new String(key, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue