Home > Backend Development > PHP Tutorial > Encryption and decryption - php keeps numbers secret after keeping them secret

Encryption and decryption - php keeps numbers secret after keeping them secret

WBOY
Release: 2016-08-18 09:16:02
Original
3081 people have browsed it

How to encrypt numbers in php? After encryption, they are still numbers, similar to the numbers in Zhihu or segmentfault URLs

Reply content:

How to encrypt numbers in php? After encryption, they are still numbers, similar to the numbers in Zhihu or segmentfault URLs

Strictly speaking, this urlencode is not encryption, it is just encoding. For example, the ASCII value of a space is 32, which corresponds to 20 in hexadecimal, so it is %20 (the function will specially convert it into +), and numbers and letters are not processed.
I think if you want to implement it, you can use regular expressions to process strings in a loop. Except for numbers, which are not processed, everything else is divided into small segments and used for symmetric encryption. Decryption can also be achieved

You can simply add salt to the number to perform md5
md5($id . $salt)
Convert the first N digits to decimal (the md5 result is equivalent to a hexadecimal number), then intercept the first N digits
and then The above results are confused with the original ID according to certain rules

If it’s not enough, you can also convert the ID to octal and then confuse it again

The password_hash() function is commonly used for PHP form data encryption, please go read the documentation

Thank you for the invitation. You can use md5 directly

<code>echo md5(123456);</code>
Copy after login

You can use sprintf format encoding

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template