Files
novalon-manage-system/test_bcrypt.py
T
张翔 af44c23f21 refactor(security): 重构安全配置并优化测试环境
- 移除旧的测试套件和UAT测试文件
- 更新密码编码器配置使用BCrypt strength=12
- 添加用户角色关联表和相关服务
- 优化前端日期显示格式
- 清理无用资源和配置文件
- 增强测试数据管理和清理功能
2026-03-27 13:00:22 +08:00

22 lines
902 B
Python

import bcrypt
# 测试密码编码器强度问题
password = "admin123"
# 测试strength=10的编码器
encoder_10 = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(10))
print(f"Strength=10: {encoder_10.decode('utf-8')}")
print(f"Length: {len(encoder_10)}")
# 测试strength=12的编码器
encoder_12 = bcrypt.hashpw(password.encode('utf-8'), bcrypt.gensalt(12))
print(f"Strength=12: {encoder_12.decode('utf-8')}")
print(f"Length: {len(encoder_12)}")
# 测试验证
print(f"\n验证strength=10的密码: {bcrypt.checkpw(password.encode('utf-8'), encoder_10)}")
print(f"验证strength=12的密码: {bcrypt.checkpw(password.encode('utf-8'), encoder_12)}")
# 测试交叉验证
print(f"\n用strength=10验证strength=12的密码: {bcrypt.checkpw(password.encode('utf-8'), encoder_12)}")
print(f"用strength=12验证strength=10的密码: {bcrypt.checkpw(password.encode('utf-8'), encoder_10)}")