1 package org
.asamk
.signal
.util
;
3 import org
.whispersystems
.signalservice
.internal
.util
.Base64
;
6 import java
.io
.IOException
;
7 import java
.security
.NoSuchAlgorithmException
;
8 import java
.security
.SecureRandom
;
11 public static String
getSecret(int size
) {
12 byte[] secret
= getSecretBytes(size
);
13 return Base64
.encodeBytes(secret
);
16 public static byte[] getSecretBytes(int size
) {
17 byte[] secret
= new byte[size
];
18 getSecureRandom().nextBytes(secret
);
22 private static SecureRandom
getSecureRandom() {
24 return SecureRandom
.getInstance("SHA1PRNG");
25 } catch (NoSuchAlgorithmException e
) {
26 throw new AssertionError(e
);
30 public static File
createTempFile() throws IOException
{
31 return File
.createTempFile("signal_tmp_", ".tmp");