.NET短唯一标识符 [英] .NET Short Unique Identifier

查看:135
本文介绍了.NET短唯一标识符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要.NET中的唯一标识符(不能使用GUID,因为在这种情况下它太长了。)

I need a unique identifier in .NET (cannot use GUID as it is too long for this case).

人们是否认为该算法使用了此处是不错的候选人,或者您有还有其他建议吗?

Do people think that the algorithm used here is a good candidate or do you have any other suggestions?

推荐答案

这是一个不错的建议- http://www.singular.co。 nz / blog / archive / 2007/12/20 / shortguid-a-shorter-and-url-friendly-guid-in-c-sharp.aspx

This one a good one - http://www.singular.co.nz/blog/archive/2007/12/20/shortguid-a-shorter-and-url-friendly-guid-in-c-sharp.aspx

以及此处
类似YouTube的GUID

您可以使用Base64:

You could use Base64:

string base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray());




生成的字符串类似于E1HKfn68Pkms5zsZsvKONw ==。由于GUID总是
128位,因此您可以忽略==,因为您知道结尾总是
且将为您提供22个字符串。
并不比YouTube短。

That generates a string like E1HKfn68Pkms5zsZsvKONw==. Since a GUID is always 128 bits, you can omit the == that you know will always be present at the end and that will give you a 22 character string. This isn't as short as YouTube though.

这篇关于.NET短唯一标识符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆