生成随机字符串
@param length 长度
@return 长度为length的字符串
503582
public static String generate(Integer length) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < length; i++) {
            int number = random.nextInt(seed.length());
            sb.append(seed.charAt(number));
        }
        return sb.toString();
    }
263158
public static long[] getLongIndexArray(int length) {
        long[] index = new long[length];
        for (int i=0; i<index.length; i++) {
            index[i] = i;
        }
        return index;
    }
484061
public static byte[] getIndexArray(int length) {
        byte[] index = new byte[length];
        for (int i=0; i<index.length; i++) {
            index[i] = (byte) i;
        }
        return index;
    }
1188755
public static int writeLength(int valueLength, OutputStream out) throws IOException {
        if (valueLength < 128) {
            out.write(valueLength);
            return 1;
        } else if (valueLength < 16384) {
            out.write((valueLength >> 8) | 0x80);
            out.write(valueLength);
            return 2;
        } else if (valueLength < 2097152) {
            out.write((valueLength >> 16) | 0xc0);
            out.write(valueLength >> 8);
            out.write(valueLength);
            return 3;
        } else if (valueLength < 268435456) {
            out.write((valueLength >> 24) | 0xe0);
            out.write(valueLength >> 16);
            out.write(valueLength >> 8);
            out.write(valueLength);
            return 4;
        } else {
            out.write(0xf0);
            out.write(valueLength >> 24);
            out.write(valueLength >> 16);
            out.write(valueLength >> 8);
            out.write(valueLength);
            return 5;
        }
    }
773528
public static byte[] getKey(Integer length) {
        if (!AESUtil.SHORT.equals(length) && !AESUtil.MIDDLE.equals(length) && !AESUtil.LONG.equals(length)) {
            throw new RuntimeException("指定的KeySize不正确");
        }
        SecretKey key = null;
        try {
            KeyGenerator keyGen = KeyGenerator.getInstance("AES");
            keyGen.init(length);
            key = keyGen.generateKey();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        return key.getEncoded();
    }
1010726
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();
    }
288203
def _make_random_string(length):
    
    chars = string.ascii_lowercase + string.ascii_uppercase + string.digits
    return ''.join(random.choice(chars) for x in range(length))
1265555
public int getLength() {
        int length = 8;

        int size = mAttributes.size();
        for (int i=0; i<size; i++) {
            length += mAttributes.get(i).getLength();
        }

        return length;
    }
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();
	}
1210204
public static String generateMixString(int length) {
		StringBuffer sb = new StringBuffer();
		Random random = new Random();
		for (int i = 0; i < length; i++) {
			sb.append(allChar.charAt(random.nextInt(letterChar.length())));
		}
		return sb.toString();
	}
797680
public static UTF8String blankString(int length) {
    byte[] spaces = new byte[length];
    Arrays.fill(spaces, (byte) ' ');
    return fromBytes(spaces);
  }
584986
public static String getRandomHexString(int length){
        byte[] bytes = new byte[length/2];
        new Random().nextBytes(bytes);
        return DatatypeConverter.printHexBinary(bytes);
    }
1236140
public static String createRandomNum(int length) {
        if (length < 0) {
            throw new IllegalArgumentException("长度不能小于0");
        }
        char[] chars = new char[length];
        for (int i = 0; i < length; i++) {
            chars[i] = (char) ((Math.random() * 10) + 48);
        }
        return new String(chars);
    }
703149
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();
	}
984872
public static String password(int length) {
        StringBuilder result = new StringBuilder();

        byte[] values = byteArray(length);
        // We use a modulus of an increasing index rather than of the byte values
        // to avoid certain characters coming up more often.
        int index = 0;

        for (int i = 0; i < length; i++) {
            index += (values[i] & 0xff);
            index = index % passwordCharacters.length();
            result.append(passwordCharacters.charAt(index));
        }

        return result.toString();
    }
734301
public static String getSpaces(int length) {
        char[] charArray = new char[length];
        Arrays.fill(charArray, ' ');
        String str = new String(charArray);
        return str;
    }
17451
public static String randomAsciiFixLength(Random random, int length) {
		return RandomStringUtils.random(length, 32, 127, false, false, null, random);
	}