-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestBCrypt.java
More file actions
20 lines (15 loc) · 782 Bytes
/
TestBCrypt.java
File metadata and controls
20 lines (15 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
public class TestBCrypt {
public static void main(String[] args) {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
String password = "Admin123!";
String hashedPassword = encoder.encode(password);
System.out.println("Password: " + password);
System.out.println("Hashed: " + hashedPassword);
// 測試現有哈希
String existingHash = "$2a$10$92IXUNpkjO0rOQ5byMi.Ye4oKoEa3Ro9llC/.og/at2.uheWG/igi";
boolean matches = encoder.matches(password, existingHash);
System.out.println("Existing hash matches: " + matches);
System.out.println("Existing hash: " + existingHash);
}
}