code: public static String generateRandomKey (Random rand, int length)
      {
          int numKeyChars = KEY_CHARS.length();
          StringBuilder buf = new StringBuilder();
          for (int ii = 0; ii < length; ii++) {
              buf.append(KEY_CHARS.charAt(rand.nextInt(numKeyChars)));
          }
          return buf.toString();
      }
docs: Return a key of the given length that contains random numbers.