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)}")