YouTube-like GUID

后端 未结 8 1848
灰色年华
灰色年华 2020-12-07 16:17

Is it possible to generate short GUID like in YouTube (N7Et6c9nL9w)?

How can it be done? I want to use it in web app.

8条回答
  •  忘掉有多难
    2020-12-07 17:08

    9 chars is not a GUID. Given that, you could use the hexadecimal representation of an int, which gives you a 8 char string.

    You can use an id you might already have. Also you can use .GetHashCode against different simple types and there you have a different int. You can also xor different fields. And if you are into it, you might even use a Random number - hey, you have well above 2.000.000.000+ possible values if you stick to the positives ;)

提交回复
热议问题