Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想生成一个 16 个字符的字母数字会话 ID 字符串。这样做的最佳方法是什么,以保证每次生成的字符串都是唯一的?
注意:我将使用 C++ 生成会话 ID。
通常,您将使用提供此类服务的任何语言/操作系统服务来创建GUID 。常用的 GUID 长度为 16个字节,以十六进制表示为 32 个字符。您可以对其进行base64编码并使其稍小一些(大约 22 个字符)。你真的需要正好 16 个字符吗?
使用 GUID。您如何生成一个将取决于您运行的平台。