Enhance the security of User Password Storage and Inspection

Source: Internet
Author: User

The following $ username and $ password respectively refer to the user name and password, and $ sitekey is the site scrambling code.

Password settings

<Input type = "password" name = "passwd"/>
<Input type = "hidden" name = "t_code0"/>

Use javascript for processing when submitting


T_code0.value = md5 (username. value "|" passwd. value );
Passwd. value = '';

If the submitted passwd has a value or t_code0 is null, the password setting fails;

The t_code0 value is saved to the save_pwd field of the database;


Password Verification

1. log on to the client
The server generates a random code $ sid, saves it to $ _ SESSION [sid], and passes it to the user;

Form


<Input type = "hidden" name = "sid" value = "..."/>
<Input name = "username"/>
<Input type = "password" name = "passwd"/>
<Input type = "hidden" name = "t_code"/>

2. the user enters the user name and password and uses javascript to process the submission.


Var t = md5 (username. value "|" passwd. value );
T_code.value = md5 (sid "|" t );
Passwd. value = '';
3. server-side Determination
If username is empty, passwd is not empty, or t_code is empty, return to the logon page;
If no $ _ SESSION [sid] exists, return to the logon page;


[Php]

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.