使用 Github 空间搭建 Hexo 技术博客——分享一个类似hexo admin的hexo文章管理插件hexo-myadmin(十四)

hexo-myadmin

推荐理由:轻巧方便,

只有 post 和 page 添加删除修改这几个简单的功能 ,而且用的是一些轻量级的库,容易理解和接受

1.安装hexo-myadmin的插件

npm i hexo-myadmin --save

2.启动服务

hexo server

3.测试登录,网页输入localhost:4000/admin 

自动跳转到下图显示页面即安装成功

4.设置密码保护

在_config.yml文件中添加:

admin:
  username: 你自己设置登录名
  password_hash: 你想设置密码生成的bcrypt hash安全密钥
  secret: a secret something

The secret is used to make the cookies secure

获取bcrypt安全密钥地址:https://bcrypt-generator.com/

设置并放置好之后,重新hexo s或hexo server操作,然后会进入登录页面

输入账号密码登录即可,注意输入的密码是你加密之前的密码

如果不会加密bcrypt,可以参考我下面的代码:

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
    }

}

欧克啦,现在开始后台文章编写啦

提示ctrl+P是预览功能哦

写的时候可以常按这个查看格式,好滴哟

发布了120 篇原创文章 · 获赞 201 · 访问量 23万+

猜你喜欢

转载自blog.csdn.net/wugenqiang/article/details/88409679