带有哈希值 (md5) 的漂亮 URL
在我们的网络应用程序中,我们显示脉冲列表,但为了链接等,我们使每个脉冲都唯一可用。在我们的 Couch DB 中,我们通过 md5 处理每个脉冲的独特属性,为每个脉冲赋予一个唯一的 ID。 IE:www.foo.com/bar/
尽管这些 md5 和非常长并且会产生丑陋的 URL。是否有另一种方法来散列属性,该方法需要更少的字符但仍保证唯一性。
多谢
In our web application we display a list of pulses, but for linking and such we make every pulse uniquely available. In our Couch DB we are giving every pulse a unique id by md5'ing their unique attributes. I.E.: www.foo.com/bar/
Though these md5 sums are extremely long and make for ugly URLs. Is there another way to hash the attributes that will require less characters but still guarantee uniqueness.
Thanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用方法 像这样创建一个
给定长度
的随机字符串
,其中包含某些字符< /code> 并将其插入到旁边的一行中
md5
行,用于使用“pretty url”字符串从数据库检索数据。需要考虑的一件事是从可能的字符中取出元音,就像它们一样,你最终可能会得到不好的单词:)当然,还要确保它不存在于数据库中,如果它确实存在的话另一种……不过这种情况不会经常发生。Instead of creating an ugly
md5
you could use a method like this to create arandom string
of agiven length
containingcertain characters
and insert this into a row next to themd5
row that is used for retrieving the data from the database using the 'pretty url' string. One thing to think about would be to take out the vowels from the possible characters as with them, you could end up with bad words :) Also, make sure it does not already exist in the database of course, and if it does just create another one... that won't happen very often though.