Recommended reason: light and convenient,
Only post and page add, delete and modify these simple functions, and use some lightweight libraries, easy to understand and accept
1. Install the plugin for hexo-myadmin
npm i hexo-myadmin --save
2. Start the service
hexo server
3. Test login, enter localhost: 4000 / admin
Automatically jump to the page shown in the figure below and the installation is successful
4. Set password protection
Add in the _config.yml file:
admin:
username: 你自己设置登录名
password_hash: 你想设置密码生成的bcrypt hash安全密钥
secret: a secret something
The secret
is used to make the cookies secure
Get the address of the bcrypt security key: https://bcrypt-generator.com/
After setting and placing, re-hexo s or hexo server operation, and then will enter the login page
Enter the account password to log in. Note that the password you entered is the password you encrypted before
If you don't encrypt bcrypt, you can refer to my code below:
package com.wugenqiang.utils.encrypt;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
/**
* @Classname BCryptUtils
* @Description BCrypt-hash加密工具类
* @Date 2019/3/11 21:53
* @Created by WuGenQiang//fighting!!
*/
public class BCryptUtils {
/**
* 对密码进行加密
* @param password
* @return
*/
public static String encode(String password) {
BCryptPasswordEncoder bcryptPasswordEncoder = new BCryptPasswordEncoder();
String hashPass = bcryptPasswordEncoder.encode(password);
return hashPass;
}
/**
* 对原密码和已加密的密码进行匹配,判断是否相等
* @param password
* @param encodedPassword
* @return
*/
public static boolean match(String password,String encodedPassword) {
BCryptPasswordEncoder bcryptPasswordEncoder = new BCryptPasswordEncoder();
boolean result = bcryptPasswordEncoder.matches(password, encodedPassword);
return result;
}
//测试
public static void main(String[] args) {
String hashPass = encode("123456");
System.out.println(hashPass);
System.out.println(match("123456",hashPass));//true
System.out.println(match("123456","$2a$10$7wOQPHU2MfHt3X4wCFx5H.EZu.rlHMtY5HTFsqXiPd6BA5vNHJNf2"));//true
System.out.println(match("123456","$2a$10$nYQWXcY.eVUwI8kYGtMCVOD0hWE4AKjzFg0oo91qc/ECQg/DD/CpS"));//true
System.out.println(match("123456","$2a$10$9etIPtquQ3f..ACQkDHAVuBfjBoDXXWHHCOBl/RaJADxuXdSQB6I2"));//true
}
}
Ok, now we are writing background articles
Prompt ctrl + P is the preview function
When you write, you can always check the format according to this.