mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-03 09:42:19 +00:00
Simplify access to SecureRandom
This shouldn't matter at all, but it's more "correct," and shows my age less.
This commit is contained in:
committed by
Greyson Parrelli
parent
8aa185070b
commit
a52c295a38
@@ -308,13 +308,9 @@ public class GroupDatabase extends Database {
|
||||
|
||||
|
||||
public byte[] allocateGroupId() {
|
||||
try {
|
||||
byte[] groupId = new byte[16];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(groupId);
|
||||
return groupId;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
byte[] groupId = new byte[16];
|
||||
new SecureRandom().nextBytes(groupId);
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public static class Reader implements Closeable {
|
||||
|
||||
@@ -71,7 +71,6 @@ import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -1279,13 +1278,9 @@ public class MmsDatabase extends MessagingDatabase {
|
||||
private final long threadId;
|
||||
|
||||
public OutgoingMessageReader(OutgoingMediaMessage message, long threadId) {
|
||||
try {
|
||||
this.message = message;
|
||||
this.id = SecureRandom.getInstance("SHA1PRNG").nextLong();
|
||||
this.threadId = threadId;
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
this.message = message;
|
||||
this.id = new SecureRandom().nextLong();
|
||||
this.threadId = threadId;
|
||||
}
|
||||
|
||||
public MessageRecord getCurrent() {
|
||||
|
||||
@@ -47,7 +47,6 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -818,13 +817,9 @@ public class SmsDatabase extends MessagingDatabase {
|
||||
private final long threadId;
|
||||
|
||||
public OutgoingMessageReader(OutgoingTextMessage message, long threadId) {
|
||||
try {
|
||||
this.message = message;
|
||||
this.threadId = threadId;
|
||||
this.id = SecureRandom.getInstance("SHA1PRNG").nextLong();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
this.message = message;
|
||||
this.threadId = threadId;
|
||||
this.id = new SecureRandom().nextLong();
|
||||
}
|
||||
|
||||
public MessageRecord getCurrent() {
|
||||
|
||||
Reference in New Issue
Block a user