be1c587dbf
- 修复密码哈希格式问题(从$2a$改为$2b$) - 更新所有测试用例密码从Test@123改为admin123 - 修改测试2.3、2.5、2.6,避免操作admin用户(第1行) - 在beforeEach中添加页面初始化,避免localStorage访问错误 - 添加测试数据清理机制
22 lines
805 B
Java
22 lines
805 B
Java
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
public class PasswordTest {
|
|
public static void main(String[] args) {
|
|
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(12);
|
|
|
|
String hash = "$2a$12$nZ1EMUpZQljbnEdIKzH72eHlDJKUmHmHppnTTVth/SlHs5VpSAr8C";
|
|
|
|
// 测试常见密码
|
|
String[] passwords = {"admin", "Admin@123", "Test@123", "password", "123456", "admin123"};
|
|
|
|
for (String password : passwords) {
|
|
boolean matches = encoder.matches(password, hash);
|
|
System.out.println(password + ": " + matches);
|
|
}
|
|
|
|
// 生成新的哈希
|
|
String newHash = encoder.encode("Test@123");
|
|
System.out.println("\nNew hash for 'Test@123': " + newHash);
|
|
}
|
|
}
|