I know I can use GUID to generate a unique string, but it’s too long.
Now I only need generate un-duplicate string within an website, how can I do? Thanks!
For example: In the website http://mathurl.com/, you can generate a permanent URL, such as http://mathurl.com/75ujy7b and 75ujy7b is very short and un-duplicate.
First of all you can start with a counter that you make sure using Mutex/lock that return unique incremental numbers, and you save the last number somewhere on your site, maybe in web.config, maybe in database, or in a file.
Then you convert this unique number to a different base number, eg to a base-64. Here is some code, and mode details on how you can do that
https://stackoverflow.com/a/5901201/159270
And you can get results like
Now, if you scramble the map on the characters you can also make a not so easy to find number.