package io.renren.common.utils;

import java.util.Random;

public class RandomGen {
    /**
     * 随机生成n位的4进制字符串
     *
     * @return
     */
    private static String randomlyGenerateCharacters() {
        Random random = new Random();
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int rand = random.nextInt(36);
            if (rand < 10) {
                res.append((char) ('0' + rand));
            } else {
                res.append((char) ('a' + (rand - 10)));
            }
        }
        return res.toString();
    }

    /**
     * 格式化名字
     *
     * @return
     */
    public static String formatName(String name) {
        String res = "";
        res = randomlyGenerateCharacters() + name.toLowerCase();
        return res;
    }
}
