Implement contact manager methods for pending contacts.

This commit is contained in:
akwizgran
2019-04-17 17:00:59 +01:00
parent fc8ca872a8
commit fa562b40bc
9 changed files with 158 additions and 37 deletions

View File

@@ -37,7 +37,7 @@ public class Base32 {
return s.toString();
}
public static byte[] decode(String s) {
public static byte[] decode(String s, boolean strict) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
int digitIndex = 0, digitCount = s.length(), currentByte = 0x00;
int byteMask = 0x80, codeMask = 0x10;
@@ -61,7 +61,7 @@ public class Base32 {
}
}
// If any extra bits were used for encoding, they should all be zero
if (byteMask != 0x80 && currentByte != 0x00)
if (strict && byteMask != 0x80 && currentByte != 0x00)
throw new IllegalArgumentException();
return b.toByteArray();
}

View File

@@ -153,4 +153,13 @@ public class StringUtils {
return new String(c);
}
public static String getRandomBase32String(int length) {
char[] c = new char[length];
for (int i = 0; i < length; i++) {
int character = random.nextInt(32);
if (character < 26) c[i] = (char) ('a' + character);
else c[i] = (char) ('2' + (character - 26));
}
return new String(c);
}
}