制作一个类似于 TinyURL.com 的短网址 [英] Making a short URL similar to TinyURL.com

查看:30
本文介绍了制作一个类似于 TinyURL.com 的短网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个新的网络应用程序,该应用程序需要生成一个内部短网址,以供将来使用,以便用户轻松返回具有很长网址的特定页面.我最初的想法是在数据库中存储一个数字并以 HEXADECIMAL 值输出它以使其比整数短.TinyURL.com 似乎使用 HEXADECIMAL(多个大小写字母与数字混合)以外的其他东西.有没有一种简单的方法来生成类似于 TinyURL 所做的事情?

I'm building a new web app that has a requirement to generate an internal short URL to be used in the future for users to easily get back to a specific page which has a very long URL. My initial thoughts are to store a number in a database and output it in a HEXADECIMAL value to keep it shorter than an integer. TinyURL.com seems to use something other than HEXADECIMAL (multiple case letters mixed with numbers). Is there an easy way to generate something similar what TinyURL does?

推荐答案

请查看这个关于主题的很好的解释:随机 TinyURL 浏览器(更新).

Please, check out this good explanation on subject: Random TinyURL Browser (Updated) .

重要部分:

正如我们所确定的,TinyURL 有 62,193,780 个可能的值.TinyURL 由 Base 36 哈希生成(36 表示字符数 az 和 0-9,可以从中构造 TinyURL 的可能值数组),由 MySQL 自动递增,初始值计数为零.

As we have established, there are 62,193,780 possible values for TinyURL's. TinyURL's are generated by a Base 36 hash (36 indicating the number of characters a-z and 0-9, the array of possible values out of which a TinyURL can be constructed), autoincremented by MySQL with an initial value count of zero.

顺便说一句,另一个类似的问题,通过数学观点:Creating your own Tinyurl style用户名.这里有一些 .NET 源代码:Base 36 type for .NET (C#)

BTW, another SO similar question, through a mathematical view : Creating your own Tinyurl style uid. And here some .NET source code: Base 36 type for .NET (C#)

这篇关于制作一个类似于 TinyURL.com 的短网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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