package com.yihu.jw.util.common;

import java.util.Random;

/**
 * Created by zdm on 2019/6/19.
 */
public class PwdUtil {

    /**
     * 获取指定长度的随机字符串
     * @param length
     * @return
     */
    public static String randomString(int length) {
        String str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        StringBuffer buffer = new StringBuffer();
        Random random = new Random();
        for (int i = 0; i < length; i++) {
            int pos = random.nextInt(str.length());
            buffer.append(str.charAt(pos));
        }
        return buffer.toString();
    }
}
