code: public static String generateBase32Secret(int length) {
  		StringBuilder sb = new StringBuilder(length);
  		Random random = new SecureRandom();
  		for (int i = 0; i < length; i++) {
  			int val = random.nextInt(32);
  			if (val < 26) {
  				sb.append((char) ('A' + val));
  			} else {
  				sb.append((char) ('2' + (val - 26)));
  			}
  		}
  		return sb.toString();
  	}
docs: Similar to {@link #generateBase32Secret()} but specifies a character length.