org.apache.commons.lang3.RandomStringUtils.random()

Here are the examples of the java api org.apache.commons.lang3.RandomStringUtils.random() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

325 Examples 7

19 Source : CryptoUtils.java
with Apache License 2.0
from zhcet-amu

public static String generatePreplacedword(int length) {
    char[] possibleCharacters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@#_-?%&*".toCharArray();
    return RandomStringUtils.random(length, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom());
}

19 Source : ShiroUtils.java
with MIT License
from yunchaoyun

/**
 * 生成随机数  盐
 * @return
 */
public static String getRandomSalt() {
    String index = RandomStringUtils.random(1, "23456789");
    String str = RandomStringUtils.random(Integer.valueOf(index), "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ");
    return str;
}

19 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机字母或数字,随机长度
 */
public static String randomStringRandomLength(int minLength, int maxLength) {
    return RandomStringUtils.random(nextInt(minLength, maxLength), 0, 0, true, true, null, threadLocalRandom());
}

19 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机ASCII字符(含字母,数字及其他符号),随机长度
 */
public static String randomAsciiRandomLength(int minLength, int maxLength) {
    return RandomStringUtils.random(nextInt(minLength, maxLength), 32, 127, false, false, null, threadLocalRandom());
}

19 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机ASCII字符(含字母,数字及其他符号),固定长度
 */
public static String randomAsciiFixLength(int length) {
    return RandomStringUtils.random(length, 32, 127, false, false, null, threadLocalRandom());
}

19 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机字母,固定长度
 */
public static String randomLetterFixLength(int length) {
    return RandomStringUtils.random(length, 0, 0, true, false, null, threadLocalRandom());
}

19 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机字母,随机长度
 */
public static String randomLetterRandomLength(int minLength, int maxLength) {
    return RandomStringUtils.random(nextInt(minLength, maxLength), 0, 0, true, false, null, threadLocalRandom());
}

19 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

// ////////////////// String/////////
/**
 * 随机字母或数字,固定长度
 */
public static String randomStringFixLength(int length) {
    return RandomStringUtils.random(length, 0, 0, true, true, null, threadLocalRandom());
}

19 Source : CodeGenerateor.java
with Apache License 2.0
from xiongzhao1217

/**
 * 随机生成字符串
 * @param count 随机字符串长度
 * @return 随机生成的字符串
 */
public static String random(int count) {
    return RandomStringUtils.random(count, randomChars);
}

19 Source : RandomPlatformViewGenerator.java
with GNU General Public License v3.0
from voyages-sncf-technologies

static String genTrigram() {
    return RandomStringUtils.random(3, true, false).toUpperCase();
}

19 Source : RandomPlatformViewGenerator.java
with GNU General Public License v3.0
from voyages-sncf-technologies

static String genNameOrValue() {
    return RandomStringUtils.random(10, true, false);
}

19 Source : MD5.java
with Apache License 2.0
from SpringCloud

/**
 * 随机生成指定长度的字符串
 * @param length 长度
 * @return string
 */
public static String randString(int length) {
    return RandomStringUtils.random(length);
}

19 Source : SpringServiceSettings.java
with Apache License 2.0
from spinnaker

public void enableAuth() {
    setBasicAuthEnabled(true);
    setUsername(RandomStringUtils.random(10));
    setPreplacedword(RandomStringUtils.random(10));
}

19 Source : KafkaThrottlingTest.java
with Apache License 2.0
from Sixt

private String randomData() {
    return RandomStringUtils.random(4096, "abcdefghijklmnopqrstuvwxyz");
}

19 Source : AmazonSnsApiCommunicatorIntegrationTest.java
with Apache License 2.0
from sflpro

/* Utility methods */
private String generateIOSToken() {
    return RandomStringUtils.random(IOS_TOKEN_LENGTH, HEX_CHARACTER_SET);
}

19 Source : ServicesTestHelper.java
with Apache License 2.0
from sflpro

/* Device tokens */
public String generateIOSToken() {
    return RandomStringUtils.random(IOS_TOKEN_LENGTH, HEX_CHARACTER_SET);
}

19 Source : TestUtils.java
with Mozilla Public License 2.0
from secdec

public static String getRandomName() {
    return RandomStringUtils.random(10, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
}

19 Source : RandomUtil.java
with GNU General Public License v2.0
from sanri1993

/**
 * 功能:生成 length 个中文 <br/>
 * 创建时间:2016-4-16上午11:24:40
 * 作者:sanri
 */
public static String chinese(int length, String src) {
    String ret = "";
    if (!StringUtils.isBlank(src)) {
        return RandomStringUtils.random(length, src.toCharArray());
    }
    for (int i = 0; i < length; i++) {
        String str = null;
        // 定义高低位
        int hightPos, lowPos;
        Random random = new Random();
        // 获取高位值
        hightPos = (176 + Math.abs(random.nextInt(39)));
        // 获取低位值
        lowPos = (161 + Math.abs(random.nextInt(93)));
        byte[] b = new byte[2];
        b[0] = (new Integer(hightPos).byteValue());
        b[1] = (new Integer(lowPos).byteValue());
        try {
            // 转成中文
            str = new String(b, "GBk");
        } catch (UnsupportedEncodingException ex) {
            ex.printStackTrace();
        }
        ret += str;
    }
    return ret;
}

19 Source : RandomUtil.java
with GNU General Public License v2.0
from sanri1993

/**
 * 功能:随机生成用户名<br/>
 * 创建时间:2017-8-13上午8:04:32<br/>
 * 作者:sanri<br/>
 * @return<br/>
 */
public static String username() {
    boolean sex = random.nextBoolean();
    int secondNameLength = RandomUtils.nextInt(1, 3);
    String firstName = RandomStringUtils.random(1, FIRST_NAME);
    String srcChars = sex ? BOY : GIRL;
    String secondName = RandomStringUtils.random(secondNameLength, srcChars);
    return firstName + secondName;
}

19 Source : ClientCredentialServiceImpl.java
with Mozilla Public License 2.0
from SafeExamBrowser

public static CharSequence generateClientId() {
    return RandomStringUtils.random(16, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom());
}

19 Source : ClientCredentialServiceImpl.java
with Mozilla Public License 2.0
from SafeExamBrowser

public static CharSequence generateClientSecret() {
    // TODO find a better way to generate a random char array instead of using RandomStringUtils.random which uses a String
    return RandomStringUtils.random(64, 0, possibleCharacters.length - 1, false, false, possibleCharacters, new SecureRandom());
}

19 Source : PepperGenerator.java
with Apache License 2.0
from Password4j

/**
 * Generates a {@link String} that can be used as pepper
 * by a CHF.
 * The generated pepper is created by a cryptographically
 * strong random number generator (RNG).
 * <p>
 * The parameter length must be a non-negative number,
 * otherwise a {@link BadParametersException} is thrown.
 *
 * @param length of the returned string
 * @return a pepper of the given length
 * @throws BadParametersException if the length is negative
 * @since 0.1.1
 */
public static String generate(int length) {
    if (length < 0) {
        throw new BadParametersException("Pepper length cannot be negative");
    }
    return RandomStringUtils.random(length, 32, 126, false, false, null, AlgorithmFinder.getSecureRandom());
}

19 Source : RandomUtil.java
with MIT License
from PacktPublishing

private static String generateRandomAlphanumericString() {
    return RandomStringUtils.random(DEF_COUNT, 0, 0, true, true, null, SECURE_RANDOM);
}

19 Source : CaptchaGenerator.java
with Apache License 2.0
from open-hand

/**
 * @param count 位数
 * @return 指定位数的字符验证码
 */
public static String generateCharCaptcha(int count) {
    return RandomStringUtils.random(count, 0, CHARS.length - 1, true, true, CHARS);
}

19 Source : CaptchaGenerator.java
with Apache License 2.0
from open-hand

/**
 * @param count 位数
 * @return 指定位数的数字验证码
 */
public static String generateNumberCaptcha(int count, char[] source) {
    return RandomStringUtils.random(count, 0, source.length - 1, false, true, source);
}

19 Source : CaptchaGenerator.java
with Apache License 2.0
from open-hand

/**
 * @param count 位数
 * @return 指定位数的数字验证码
 */
public static String generateNumberCaptcha(int count) {
    return RandomStringUtils.random(count, 0, NUMBERS.length - 1, false, true, NUMBERS);
}

19 Source : ServerDialback.java
with Apache License 2.0
from ma1uta

/**
 * Generate a new dialback key.
 *
 * @param streamId stream id.
 * @return dialback key.
 */
public String newKey(String streamId) {
    String secretKey = RandomStringUtils.random(KEY_LENGTH, 0, 0, true, true, null, this.random);
    keyCache.put(streamId, secretKey);
    return genKey(streamId, secretKey);
}

19 Source : RandomUtil.java
with Apache License 2.0
from jhipster

/**
 * <p>generateRandomAlphanumericString.</p>
 *
 * @return a {@link java.lang.String} object.
 */
public static String generateRandomAlphanumericString() {
    return RandomStringUtils.random(DEF_COUNT, 0, 0, true, true, null, SECURE_RANDOM);
}

19 Source : RandomUtils.java
with Apache License 2.0
from helloworldtang

/**
 * 获取一个随机的字符串
 *
 * @param count
 * @return
 */
public static String generateRandomString(int count) {
    return RandomStringUtils.random(count, true, true);
}

19 Source : RandomUtils.java
with Apache License 2.0
from helloworldtang

public static String generateRandomNum(int count) {
    return RandomStringUtils.random(count, false, true);
}

19 Source : CommonUtil.java
with MIT License
from GoldSubmarine

/**
 * 获取随机数字
 */
public static String getRandomNum(int length) {
    return RandomStringUtils.random(length, "0123456789");
}

19 Source : PasswordGenerationService.java
with Apache License 2.0
from FINRAOS

private String getStrongPreplacedword(int length) {
    return RandomStringUtils.random(length, 0, 0, true, true, null, rand);
}

19 Source : FixUtil.java
with Apache License 2.0
from exactpro

public static synchronized String generateClorIDSpecLng(int length) {
    return RandomStringUtils.random(length, "0123456789");
}

19 Source : ProjectUtils.java
with Apache License 2.0
from epirus-io

public static String generateWalletPreplacedword() {
    return RandomStringUtils.random(10, true, true);
}

19 Source : DataGenerator.java
with Apache License 2.0
from DSC-SPIDAL

private static String generateRandom(int length) {
    boolean useLetters = true;
    boolean useNumbers = false;
    return RandomStringUtils.random(length, useLetters, useNumbers);
}

19 Source : FileOutputWriter.java
with Apache License 2.0
from DSC-SPIDAL

public static String generateRandom(int length) {
    boolean useLetters = true;
    boolean useNumbers = false;
    return RandomStringUtils.random(length, useLetters, useNumbers);
}

19 Source : StringUtils.java
with Apache License 2.0
from DeNA

public static String randomUUID() {
    /* UUID sample: a3faf181-996a-457d-831f-18767419788c */
    StringBuilder sb = new StringBuilder();
    sb.append(RandomStringUtils.random(8, "0123456789abcdef"));
    sb.append("-");
    sb.append(RandomStringUtils.random(4, "0123456789abcdef"));
    sb.append("-");
    sb.append(RandomStringUtils.random(4, "0123456789abcdef"));
    sb.append("-");
    sb.append(RandomStringUtils.random(4, "0123456789abcdef"));
    sb.append("-");
    sb.append(RandomStringUtils.random(12, "0123456789abcdef"));
    return sb.toString();
}

19 Source : TikTokLogicHelper.java
with MIT License
from cyrus07424

/**
 * Get openudid.
 *
 * @return
 */
public static String getOpenudid() {
    return RandomStringUtils.random(16, "0123456789abcdef");
}

19 Source : StringUtils.java
with Apache License 2.0
from chenhaoxiang

/**
 * 获取随机字符串
 *
 * @param count 字符串长度
 * @return count长度的随机字符串
 */
public static String getRandomString(int count) {
    return RandomStringUtils.random(count, strDigits);
}

19 Source : TokenHandler.java
with MIT License
from bakdata

/**
 * Generate a random secret.
 */
public static String generateTokenSecret() {
    return RandomStringUtils.random(TOKEN_SECRET_LENGTH, 0, 0, false, false, null, RANDOM_GEN);
}

19 Source : AuthUtils.java
with MIT License
from ayushman1024

public static String OTP(int len) {
    // RandomStringUtils.random(len, "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ");
    String numbers = "0123456789#$&*!";
    String alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    return RandomStringUtils.random(8, numbers + alpha);
}

19 Source : IdentifierUtils.java
with Apache License 2.0
from aws-cloudformation

/**
 * For named resources, use this method to safely generate a user friendly
 * resource name when the customer does not preplaced in an explicit name For more
 * info, see the named resources section of the developer guide https://...
 *
 * @param logicalResourceId logical name for the resource as defined in
 *            CloudFormation
 * @param clientRequestToken the idempotent token from CloudFormation to help
 *            detect duplicate calls
 * @param maxLength the maximum length size for the identifier
 * @return generated ID string
 */
public static String generateResourceIdentifier(final String logicalResourceId, final String clientRequestToken, final int maxLength) {
    int maxLogicalIdLength = maxLength - (GUID_LENGTH + 1);
    int endIndex = Math.min(logicalResourceId.length(), maxLogicalIdLength);
    StringBuilder sb = new StringBuilder();
    if (endIndex > 0) {
        sb.append(logicalResourceId.substring(0, endIndex)).append("-");
    }
    return sb.append(RandomStringUtils.random(GUID_LENGTH, 0, 0, true, true, null, new Random(clientRequestToken.hashCode()))).toString();
}

19 Source : OpaqueTokenService.java
with Apache License 2.0
from andifalk

public String createToken() {
    return RandomStringUtils.random(48, true, true);
}

19 Source : RandomUtil.java
with MIT License
from aiyoyoyo

/**
 * 生成对应长度的随机字符串,字符范围[A-Z][a~z][0-9]
 * 每千万次,8位在千万分之1
 * @param _length 长度
 * @return 字符串
 */
public static String s_random_string(int _length) {
    return RandomStringUtils.random(_length, RandomString);
}

19 Source : IOsTest.java
with MIT License
from airbytehq

@Test
public void testGetTailDoesNotExist() throws IOException {
    List<String> tail = IOs.getTail(100, Path.of(RandomStringUtils.random(100)));
    replacedertEquals(Collections.emptyList(), tail);
}

19 Source : KeyStoreGeneratorImpl.java
with Apache License 2.0
from adorsys

private String getSecureRandomAlias() {
    SecureRandom secureRandomInstance = new SecureRandom();
    String random = RandomStringUtils.random(5, 0, 0, true, true, null, secureRandomInstance);
    return serverKeyPairAliasPrefix + random.toUpperCase();
}

19 Source : RandomUtils.java
with Apache License 2.0
from adorsys

public static String randomString(int length, boolean letters, boolean numbers) {
    // NOSONAR
    return RandomStringUtils.random(length, 0, 0, letters, numbers, null, random);
}

18 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机ASCII字符(含字母,数字及其他符号),随机长度
 */
public static String randomAsciiRandomLength(Random random, int minLength, int maxLength) {
    return RandomStringUtils.random(nextInt(random, minLength, maxLength), 32, 127, false, false, null, random);
}

18 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机字母或数字,固定长度
 */
public static String randomStringFixLength(Random random, int length) {
    return RandomStringUtils.random(length, 0, 0, true, true, null, random);
}

18 Source : RandomUtil.java
with Apache License 2.0
from xuminwlt

/**
 * 随机ASCII字符(含字母,数字及其他符号),固定长度
 */
public static String randomAsciiFixLength(Random random, int length) {
    return RandomStringUtils.random(length, 32, 127, false, false, null, random);
}

See More Examples