我正在构建一个新的网络应用程序,该应用程序需要生成一个内部的短URL以供将来使用,以便用户轻松地返回到具有非常长的URL的特定页面.我的初步想法是将数字存储在数据库中,并将其输出为HEXADECIMAL值以使其短于整数. TinyURL.com似乎使用除了HEXADECIMAL之外的其他东西(多个字母数字与数字混合).有什么简单的方法可以产生类似TinyURL的东西吗?
解决方法
请查看这个关于主题的良好解释:
Random TinyURL Browser (Updated) .
重要部分:
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.
BTW,另一个SO类似的问题,通过数学观点:Creating your own Tinyurl style uid.这里有一些.NET源代码:Base 36 type for .NET (C#)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。