我想生成具有以下属性的字符串 id:
- 简短,最多 5-6 个 apha + 数字
- 随机的
- 独特的,渴望的,但不像第一个那么重要
目前我正在考虑:
- 使用https://developers.google.com/appengine/docs/python/datastore/functions#allocate_ids分配唯一 ID
- 用一些密钥对其进行哈希处理,md5(id + secret)
- 取前 5 个符号
有没有更好的办法?我也想过使用 datacenter_id + instance_id + request_id ,但我不知道它是否会更好。