PHP string shortened

Source: Internet
Author: User
Tags crc32
Demand

$str = ' topics/new?forum_id=php ';

echo Shorturl ($STR)//output: js4d8x5d

echo unshorturl (' js4d8x5d ')//restore string output: topics/new?forum_id=php


Finding Shorturl and Unshorturl functions


Reply to discussion (solution)

No coding rules, how to write a program?

Short link?
hash function + Hash collision solution

Sina's short URL seems to be the corresponding relationship between the URL and ID number stored in the server. Not studied.

Short link?
hash function + Hash collision solution

Sina's short URL seems to be the corresponding relationship between the URL and ID number stored in the server. Not studied.
En short connection, corresponding storage too much trouble ~ Too many hash this type of PHP system functions a lot, but is one-way. My ideal is the CRC32 function 8-bit result, but CRC32 can not be reversed

No coding rules, how to write a program?
That's the question.

Constrained space is limited only by calculation.
Assuming that the original string does not contain Chinese, it can be represented by 96 binary 0000000-1011111
But it only tightens 1/8.

So the short URLs are all based on the table, providing only the table item index

Constrained space is limited only by calculation.
Assuming that the original string does not contain Chinese, it can be represented by 96 binary 0000000-1011111
But it only tightens 1/8.

So the short URLs are all based on the table, providing only the table item index
Oh, want to learn the URL of this website http://hangzhou.8684.cn/z_d7bc763d

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.