Simple encryption method for passwords

一个新手
Release: 2017-10-20 11:04:04
Original
2060 people have browsed it

General user passwords are also encrypted on the server and cannot be seen in plain text. If you want to remember to prevent users from logging in to the website again without entering their account and password, you can record it through cookies, sessionStorage, and localStorage.

Scenario: After the user successfully logs in once, he or she can log in again without losing the account number and password! Save it locally and don't want it to be displayed in plain text. It can only be encrypted and saved (general encryption is irreversible)

1. A simple encryption and decryption (there is no security if the code is completely exposed)

//加密 function encrypto( str, xor, hex ) { if ( typeof str !== 'string' || typeof xor !== 'number' || typeof hex !== 'number') { return; } let resultList = []; hex = hex <= 25 ? hex : hex % 25; for ( let i=0; i
        
Copy after login
//解密 function decrypto( str, xor, hex ) { if ( typeof str !== 'string' || typeof xor !== 'number' || typeof hex !== 'number') { return; } let strCharList = []; let resultList = []; hex = hex <= 25 ? hex : hex % 25; // 解析出分割字符 let splitStr = String.fromCharCode(hex + 97); // 分割出加密字符串的加密后的每个字符 strCharList = str.split(splitStr); for ( let i=0; i
        
Copy after login

2. How to use

The above is the detailed content of Simple encryption method for passwords. For more information, please follow other related articles on the PHP Chinese website!

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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!