1 package org
.asamk
.textsecure
;
3 import java
.security
.NoSuchAlgorithmException
;
4 import java
.security
.SecureRandom
;
7 public static String
getSecret(int size
) {
8 byte[] secret
= getSecretBytes(size
);
9 return Base64
.encodeBytes(secret
);
12 public static byte[] getSecretBytes(int size
) {
13 byte[] secret
= new byte[size
];
14 getSecureRandom().nextBytes(secret
);
18 private static SecureRandom
getSecureRandom() {
20 return SecureRandom
.getInstance("SHA1PRNG");
21 } catch (NoSuchAlgorithmException e
) {
22 throw new AssertionError(e
);