Finally fixed build output
This commit is contained in:
32
src/main/java/httpServer/authorization/PasswordHasher.java
Normal file
32
src/main/java/httpServer/authorization/PasswordHasher.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package httpServer.authorization;
|
||||
|
||||
import org.springframework.security.crypto.bcrypt.BCrypt;
|
||||
|
||||
import java.util.Scanner;
|
||||
|
||||
public class PasswordHasher {
|
||||
|
||||
public static String genSalt(){
|
||||
return BCrypt.gensalt(14);
|
||||
}
|
||||
|
||||
public static String hashPassword(String password, String salt) {
|
||||
return BCrypt.hashpw(password, salt);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.print("Enter password: ");
|
||||
Scanner in = new Scanner(System.in);
|
||||
String password = in.nextLine();
|
||||
|
||||
String salt = genSalt();
|
||||
String hashed = hashPassword(password, salt);
|
||||
|
||||
System.out.println("Hashed Password: " + hashed);
|
||||
|
||||
// Example of verifying a password
|
||||
/*
|
||||
boolean matches = BCrypt.checkpw(plainPassword, storedHash);
|
||||
*/
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user