How PHP obtains a specified length of hash

Source: Internet
Author: User
Requirements: Gets the specified length of the hash, such as 4-bit, 8-bit length
Requirements:

  1. Maximum avoidance of hash collisions
  2. High execution efficiency

Reply content:

Requirements: Gets the specified length of the hash, such as 4-bit, 8-bit length
Requirements:

  1. Maximum avoidance of hash collisions
  2. High execution efficiency

Improved: substr (MD5 (Uniqid (rand (), True)), 6);

How about this?

In the case of 4-bit, there is a total of 62 *62 *62 *62=14776336 results (62=26 in English case and 10 numbers) so the probability of a hash collision is very large. Of course not to say that you cannot use a four-bit hash, if you need to hash the number of values less than this result can be fully four-bit hash.

  • 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.