Language: English | 中文
The shortcode is composed of 62 characters of [a-z, A-Z, 0-9]
, the length of the shortcode is 6 digits, and the 6-digit shortcode supports 56.8 billion combinations: (26+26+10)^6 =568002355884.
- Flexible reference library, easy to use
- Persistent storage of original data
- Self-increasing ID and MurmurHash algorithm are adopted to ensure the safety and reliability of shortcode without collision
1、Install Package
Install-Package TinyURL
2、Install the persistence library
Install-Package TinyURL.SqlServer
3、Short code
TinyURL shortUrl = new TinyURL(
new SqlServerStorageProcessor("Server=localhost;Database=TestDb;Trusted_Connection=True;"));
await shortUrl.Generator(url);
Table | UrlDictionary | |
---|---|---|
Name | Type | Details |
Id | [int] IDENTITY(1,1) NOT NULL | identity ID |
Code | [nvarchar] (6) | short code |
URL | [nvarchar] (128) | Original link |
HashVal | [nvarchar] (32) | Hash Value |
InsertAt | [datetime] | Creation time |
If you have any ideas you can join in, or find that there is code in this project that needs improvement, welcome to Fork and submit a PR!