package io.growingabit.app.utils;

import com.google.common.base.Preconditions;
import java.security.SecureRandom;
import java.util.Random;

public class SecureStringGenerator {

  // only use unreserved url characters
  private static final String symbols = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.~-";

  private final Random random = new SecureRandom();
  private final char[] buf;

  public SecureStringGenerator(final int length) {
    Preconditions.checkArgument(length > 0, "Length should be greater than 0");
    this.buf = new char[length];
  }

  public String nextString() {
    for (int idx = 0; idx < this.buf.length; ++idx) {
      this.buf[idx] = symbols.charAt(this.random.nextInt(symbols.length()));
    }
    return new String(this.buf);
  }
}

@@ -32,53 +32,8 @@
 s;%0A%0A
-import com.google.common.base.Preconditions;%0A
 impo
@@ -89,16 +89,62 @@
 andom;%0A%0A
+import com.google.common.base.Preconditions;%0A%0A
 public c
@@ -654,13 +654,13 @@
 th; 
-++
 idx
+++
 ) %7B%0A

Fix StringGeneratorTest