Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
2.3k views
in Technique[技术] by (71.8m points)

.net - Making a short URL similar to TinyURL.com

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

Important part:

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, 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#)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...