Generates an authentication token - a random string encoded in Base64.
@param length the length of the generated token
@param urlSafe switches to a URL safe encoding
@return a random string
356461
public static String generateSecurityToken(int length, boolean urlSafe) {
		final byte[] bytes = new byte[length];
		SecureRandom rand;
		try {
			rand = SecureRandom.getInstance("SHA1PRNG");
		} catch (NoSuchAlgorithmException ex) {
			logger.error(null, ex);
			rand = new SecureRandom();
		}
		rand.nextBytes(bytes);
		return urlSafe ? base64encURL(bytes) : base64enc(bytes);
	}
1144113
public static String oauthDecode(String value) throws DecoderException {
    if (value == null) {
      return "";
    }

    try {
      return new String(URLCodec.decodeUrl(value.getBytes("US-ASCII")), "UTF-8");
    }
    catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
  }
1244213
public static function generateToken($length = 32, $strong = true)
    {
        $token = base64_encode(openssl_random_pseudo_bytes($length + 10, $strong));
        $token = str_replace(['/'], '', $token);

        return substr($token, 0, $length);
    }
101593
public static String randomAsciiRandomLength(int minLength, int maxLength) {
		return RandomStringUtils.random(nextInt(minLength, maxLength), 32, 127, false, false, null,
				threadLocalRandom());
	}
1069981
public static NtlmPasswordAuthentication
                requestNtlmPasswordAuthentication( String url, SmbAuthException sae ) {
        if( auth == null ) {
            return null;
        }
        synchronized( auth ) {
            auth.url = url;
            auth.sae = sae;
            return auth.getNtlmPasswordAuthentication();
        }
    }
863716
public static String randomAsciiFixLength(int length) {
		return RandomStringUtils.random(length, 32, 127, false, false, null, threadLocalRandom());
	}
371466
public JsAPISignature createJsAPISignature(String url){
        if(jsAPITicket == null || jsAPITicket.expired()) {
            getJsAPITicket();
        }

        long timestamp = System.currentTimeMillis() / 1000;
        String nonce = RandomStringGenerator.getRandomStringByLength(16);
        String ticket = jsAPITicket.getTicket();

        try {
            String signature = SHA1.getSHA1("jsapi_ticket=" + ticket + "&noncestr=" + nonce + "&timestamp=" + timestamp + "&url=" + url);

            JsAPISignature jsAPISignature = new JsAPISignature();
            jsAPISignature.setAppId(wxClient.getClientId());
            jsAPISignature.setNonce(nonce);
            jsAPISignature.setTimestamp(timestamp);
            jsAPISignature.setSignature(signature);
            jsAPISignature.setUrl(url);
            return jsAPISignature;
        } catch (AesException e) {
            logger.error("createJsAPISignature failed", e);
            throw new WxRuntimeException(999, e.getMessage());
        }
    }
833318
def _SafeEncodeBytes(field, value):
    """"""
    try:
        if field.repeated:
            result = [base64.urlsafe_b64encode(byte) for byte in value]
        else:
            result = base64.urlsafe_b64encode(value)
        complete = True
    except TypeError:
        result = value
        complete = False
    return CodecResult(value=result, complete=complete)
1024998
public String randomString(String permitted, int length) {
        StringBuilder result = new StringBuilder(length);
        int maxIndex = permitted.length();
        for (int i = 0; i < length; i++) {
            int index = random(maxIndex);
            char value = permitted.charAt(index);
            result.append(value);
        }
        return result.toString();
    }
660830
public static String randomString(int length, @NonNull CharMatcher validChar) {
      return randomString(length, 0, Integer.MAX_VALUE, validChar);
   }
17451
public static String randomAsciiFixLength(Random random, int length) {
		return RandomStringUtils.random(length, 32, 127, false, false, null, random);
	}
1199504
public static String randomNumber(Long length, boolean padding, TestContext context) {
        return new RandomNumberFunction().execute(Arrays.asList(String.valueOf(length), String.valueOf(padding)), context);
    }
1298515
private static final String urlEncode(String s) {
        try {
            return URLEncoder.encode(s, "UTF-8");
        } catch (Exception e) {
            logger.warn("Failed to encode '" + s + "'", e);
            return s;
        }
    }
721208
public static String randomNumber(Long length, TestContext context) {
        return new RandomNumberFunction().execute(Collections.singletonList(String.valueOf(length)), context);
    }
78569
public String urlEncode(String s) {
        if (s == null || s.isEmpty()) {
            return s;
        }

        return URL.encodeQueryString(s);
    }
647820
function generator(url) {
	var randomnesss = Crypto.randomBytes(24);
	randomnesss.writeDoubleBE(Date.now(), 0);
	randomnesss.writeUInt32BE(process.pid, 8);

	var output = randomnesss.toString('base64');

	// URL safe
	if (url) {
		output = output.replace(/\//g, '_');
		output = output.replace(/\+/g, '-');
	}

	return output;
}
259698
public static String randomString(String baseString, int length) {
		final StringBuilder sb = new StringBuilder();

		if (length < 1) {
			length = 1;
		}
		int baseLength = baseString.length();
		for (int i = 0; i < length; i++) {
			int number = getRandom().nextInt(baseLength);
			sb.append(baseString.charAt(number));
		}
		return sb.toString();
	}