Encryption and decryption-php keeps the number Confidential

Source: Internet
Author: User
Tags add numbers php form
How does php encrypt a number? after encryption, it is still a number. for example, how does php encrypt a number in the url of Zhihu or segmentfault? after encryption, it is still a number, similar to the number in the url of Zhihu or segmentfault.

Reply content:

How to encrypt a number in php? after encryption, it is still a number, similar to the number in the url of Zhihu or segmentfault.

This urlencode is not strictly encrypted, but only encoded. for example, if the space ascii is 32 and the hexadecimal value is 20, it is % 20 (the function will convert it to + ), numbers and letters are not processed.
I think you can use regular expressions to process strings cyclically. in addition to not processing numbers, other functions can be divided into segments and encrypted using symmetric encryption. decryption can also be implemented.

Simply add numbers to salt for md5
Md5 ($ id. $ salt)
Convert the first N bits to the 10-digit system (the md5 result is equivalent to the 36-digit number), and then extract the first N bits.
Then, confuse the above result with the original id according to certain rules.

If it is not enough, you can convert the id into an octal format and try again.

The password_hash () function is commonly used for php form data encryption. let's take a look at the document.

Thank you for your invitation. You can directly useMd5

Echo md5 (1, 123456 );

You can use sprintf to format the encoding.

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.