mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Implement contact manager methods for pending contacts.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user