First commit

This commit is contained in:
AsamK 2015-05-11 12:55:18 +02:00
commit 28e192c519
18 changed files with 3272 additions and 0 deletions

View file

@ -0,0 +1,25 @@
package cli;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
public class Util {
public static String getSecret(int size) {
byte[] secret = getSecretBytes(size);
return Base64.encodeBytes(secret);
}
public static byte[] getSecretBytes(int size) {
byte[] secret = new byte[size];
getSecureRandom().nextBytes(secret);
return secret;
}
public static SecureRandom getSecureRandom() {
try {
return SecureRandom.getInstance("SHA1PRNG");
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
}
}