本文介绍了类似YouTube的GUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能产生的YouTube(N7Et6c9nL9w)短GUID是怎样的?
Is it possible to generate short GUID like in YouTube (N7Et6c9nL9w)?
如何能不能做到?我想用它的Web应用程序。
How can it be done? I want to use it in web app.
推荐答案
您可以使用的Base64:
You could use Base64:
string base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
这会产生像字符串E1HKfn68Pkms5zsZsvKONw ==
。由于GUID永远是128位,则可以省略 ==
,你知道永远是present在年底会给你一个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.
这篇关于类似YouTube的GUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!