mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Extract SignalAccount from Manager
This commit is contained in:
parent
701328b8c2
commit
35c72f692f
30 changed files with 793 additions and 549 deletions
47
src/main/java/org/asamk/signal/manager/KeyUtils.java
Normal file
47
src/main/java/org/asamk/signal/manager/KeyUtils.java
Normal file
|
@ -0,0 +1,47 @@
|
|||
package org.asamk.signal.manager;
|
||||
|
||||
import org.whispersystems.signalservice.internal.util.Base64;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
class KeyUtils {
|
||||
|
||||
private KeyUtils() {
|
||||
}
|
||||
|
||||
static String createSignalingKey() {
|
||||
return getSecret(52);
|
||||
}
|
||||
|
||||
static byte[] createProfileKey() {
|
||||
return getSecretBytes(32);
|
||||
}
|
||||
|
||||
static String createPassword() {
|
||||
return getSecret(18);
|
||||
}
|
||||
|
||||
static byte[] createGroupId() {
|
||||
return getSecretBytes(16);
|
||||
}
|
||||
|
||||
private static String getSecret(int size) {
|
||||
byte[] secret = getSecretBytes(size);
|
||||
return Base64.encodeBytes(secret);
|
||||
}
|
||||
|
||||
private static byte[] getSecretBytes(int size) {
|
||||
byte[] secret = new byte[size];
|
||||
getSecureRandom().nextBytes(secret);
|
||||
return secret;
|
||||
}
|
||||
|
||||
private static SecureRandom getSecureRandom() {
|
||||
try {
|
||||
return SecureRandom.getInstance("SHA1PRNG");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue