added tests, overhauled implementation of Util.hex

This commit is contained in:
2022-04-18 10:14:59 +02:00
parent 458903d755
commit 25f435677e
2 changed files with 48 additions and 6 deletions

View File

@@ -1,16 +1,12 @@
package de.srsoftware.widerhall;
import de.srsoftware.examples.translations.App;
import de.srsoftware.tools.translations.Translation;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
public class Util {
@@ -51,8 +47,10 @@ public class Util {
return buf.toString();
}
private static String hex(byte b){
return (b<16 ? "0" : "") + Integer.toHexString(b);
public static String hex(int b){
int lower = b & 0x0F;
int upper = (b & 0xF0) >> 4;
return (char)(upper < 10 ? '0'+upper : 'A'+upper-10)+""+(char)(lower < 10 ? '0'+lower : 'A'+lower-10);
}
public static String t(String tx, Object ... fills){