使用CRC较短的GUID [英] Shorter GUID using CRC

查看:190
本文介绍了使用CRC较短的GUID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在在ASP.NET网站,并希望能够拥有可通过与最终用户ID的URL访问用户配置文件。唯一标识符显然是一个不错的选择,因为它是长期(纠正我,如果我错了)不是真正的URL友好。

I am making a website in ASP.NET and want to be able to have a user profile which can be accessed via a URL with the users id at the end. Unique identifier is obviously a bad choice as it is long and (correct me if i am wrong) not really URL friendly.

我在想,如果我公司生产的ASP页面上一个独特的idnetifier然后用CRC(或者类似的东西),如果它仍然是独特(甚至是唯一的话)只是一个GUID散列它。

I was wondering if i produced a unique idnetifier on the ASP page then hashed it using CRC (or something similar) if it would still be as unique (or even unique at all) as just a GUID.

例如:

的GUID 6f1a7841-190b-4c7a-9f23-98709b6f8848等于CRC E6DC2D44。

The GUID 6f1a7841-190b-4c7a-9f23-98709b6f8848 equals CRC E6DC2D44.

感谢

推荐答案

一个GUID的CRC将不是唯一的,没有。这将是一些真棒COM pression算法,否则,要能够把一切都逼到了4个字节。

A CRC of a GUID would not be unique, no. That would be some awesome compression algorithm otherwise, to be able to put everything into just 4 bytes.

另外,如果您的用户存储在一个GUID密钥的数据库,你就会有麻烦发现了这个特殊的CRC相匹配的用户。

Also, if your users are stored in the database with a GUID key, you'd have trouble finding the user that matches up to this particular CRC.

您会被关闭使用一个普通的老整数唯一标识一个用户更好的。如果你想拥有的网址难以猜测的,你可以用一个第二票(或令牌)这就是随机生成的参数相结合。它不必是唯一的,因为在使用整数ID用于识别用户。你可以认为它或多或少作为密码。

You'd be better off using a plain old integer to uniquely identify a user. If you want to have the URL unguessable, you can combine it with a second ticket (or token) parameter that's randomly generated. It doesn't have to be unique, because you use the integer ID for identifying the user. You can think of it more or less as a password.

这篇关于使用CRC较短的GUID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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