SooHoo's recent timeline updates
SooHoo

SooHoo

V2EX member #189130, joined on 2016-08-28 16:11:45 +08:00
SooHoo's recent replies
@chemzqm 我也没有,也使用了,昨天一口气用了周额度 35% 也没出现 5 小时限额。

账号土区,但应该不仅这个问题,我另外朋友的土区就有 5 小时限额。
@wdjwxh

图,我这看着还在,微博图床,试了好久,才发成功。😭
@spamss

没问题么。。。

Thread 调用的是 run
@mscststs 我只是来特意强调下,coding 就是 tx 的。 τ ...
屏蔽完了,搜索页还有内容吗 😂,直接 Google 多好
Jan 16, 2018
Replied to a topic by xfund4 PHP 如何生成固定长度唯一随机字符串?
@SooHoo

接上 ,没发完 不小心发出来了
----------
大概思想就是把 uid 放入到串里面,然后,随机插入 不包括 uid 的字符

为了让用户稍微难些分析。就加入了进制转换,然后随机插入位置。

可能有 BUG,欢迎指正。哈哈

-----------------------------------------



/**
*
* @param count 字符个数
* @param uid 用户 id
* @return
*/
public static String randomString(int count, int uid) {

String randomKey = CODE.substring(0, 20);
String numKey = CODE.substring(20);

StringBuilder result = new StringBuilder();

while (uid > 0) { //转成 numKey.length 进制
int p = uid % numKey.length();
result.append(numKey.substring(p, p + 1));
uid = uid / numKey.length();
}

if (result.length() < count) {//字数不足,随机字符补全
Random random = new Random();
int size = count - result.length();
for (int i = 0; i < size; i++) {
int r = random.nextInt(randomKey.length()); //随机取一个字符
int p = random.nextInt(result.length() + 1);//随机一个位置
result.insert(p, randomKey.substring(r, r + 1));
}
}
return result.toString();
}
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   913 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 12ms · UTC 20:06 · PVG 04:06 · LAX 13:06 · JFK 16:06
♥ Do have faith in what you're doing.