PHP encrypted user password and login token

Source: Internet
Author: User
Found in the official PHP manual there are so many encryption algorithms, I would now like to encrypt the user's password, as well as the user login token. Can you tell me which encryption algorithm to use is better?

PS: The user password should be irreversible. User Login token should be reversible because I need to reverse token to get some information from the user.

Thanks:)

Reply content:

Found in the official PHP manual there are so many encryption algorithms, I would now like to encrypt the user's password, as well as the user login token. Can you tell me which encryption algorithm to use is better?

PS: The user password should be irreversible. User Login token should be reversible because I need to reverse token to get some information from the user.

Thanks:)

It is recommended to use the C extension of MCrypt, which encapsulates almost all cryptographic algorithms and is fast and secure.

Implementations can refer to cryptographic modules in the Laravel framework: https://github.com/laravel/framework/tree/master/src/Illuminate/Encryption

I think so: 1. Do not simply use a cryptographic algorithm directly, you can if some of your own algorithm to do this, then even if you use the algorithm is cracked, they may not be able to crack your password. An example of a simple example:


  
   

Then, if the cracked people can't get the strings behind you, they will not get your password encryption reverse engineering.

2. I've used tokens, and I've seen several other companies use tokens. At least in the inside I have seen, there is no need to reverse the situation of token to obtain information. Token is used to verify the identity, and then the information needed should be obtained from the server, rather than blindly trusting the user to submit the information. Generally speaking, the client and server should have the same encryption method. The service side, based on the same method, consolidates local and client-submitted information for calculation, obtains the same token, proves that the client has the correct authorization, and therefore gives a certain permission, rather than the use of the message.

  • Related Article

    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.