In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly explains "what is the principle of the short URL short URL system". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the principle of the short URL short URL system".
Background
Short URL generation, which is used to convert a long URL entered into a short URL. When the user requests the short URL, the service queries out the real url.
The principle of algorithm:
Algorithm 1:
1. Generate 32-bit signature string from long URL md5, which is divided into 4 segments, each with 4 bytes (that is, 32 bits)
two。 For these four segments of loop processing, take 4 bytes (32 bits) and regard it as a hexadecimal string and 0x3fffffff (30 bit 1) and operation, that is, ignore processing of more than 30 bits
3. The 30 bits are divided into 6 segments, and every 5-digit number is used as the index of the alphabet to obtain specific characters, followed by 6-bit strings.
4. Four 6-bit strings can be obtained from the total md5 string; any one of them can be used as the short url address of the long url
Algorithm 2:
The combination of numbers and characters to do a certain mapping, you can produce a unique string, such as the 62nd combination is aaaaa9, the 63rd combination is aaaaba, and then use the shuffle algorithm to disrupt the original string and save, then the combination string of the corresponding position will be a disordered combination.
Store the long URL in the database, take the returned id, and find the corresponding string. For example, if the return ID is 1, then the above string combination is bbb. Similarly, when ID is 2, the string is combined into bba, and so on. It is not possible to repeat until 62 combinations are reached, so if you use the above 62 characters and randomly take 6 characters to form a string. The possibility of repetition will not occur until your data stock reaches more than 50 billion.
Benefits
1. Let the short links survive longer and make the customer promotion better.
two。 More secure, let the domain name survive longer
3. With shorter links, more editable text will be available for posting on platforms that limit the length of the content.
4. If it is a long chain, the QR code is dense and difficult to identify, and the short chain does not have this problem.
5. Links are too long to be automatically recognized as hyperlinks on some platforms
Thank you for your reading, the above is the content of "what is the principle of the short URL short URL system". After the study of this article, I believe you have a deeper understanding of what the principle of the short URL short URL system is, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.