# PasswordUtil.java

    package com.yumu.noveltranslator.util;

    import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;

    public class PasswordUtil {

        private static final BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();

        /**
         * 对密码进行哈希加密，使用BCrypt算法
         */
        public static String hashPassword(String plainPassword) {
            return encoder.encode(plainPassword);
        }

        /**
         * 验证密码是否匹配
         */
        public static boolean verifyPassword(String plainPassword, String hashedPassword) {
            return encoder.matches(plainPassword, hashedPassword);
        }
    }