From 1119783bbe31c8201ac74a792898b683b99b341a Mon Sep 17 00:00:00 2001 From: Ahmed Elwasefi Date: Sun, 19 May 2024 16:53:31 +0300 Subject: [PATCH] Updated encryption algo for users. --- services/users/pom.xml | 6 +++--- .../com/workup/users/commands/utils/PasswordHasher.java | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/services/users/pom.xml b/services/users/pom.xml index ccba08e2..bb2b9ccf 100644 --- a/services/users/pom.xml +++ b/services/users/pom.xml @@ -123,9 +123,9 @@ - org.mindrot - jbcrypt - 0.4 + com.google.guava + guava + 32.1.3-jre diff --git a/services/users/src/main/java/com/workup/users/commands/utils/PasswordHasher.java b/services/users/src/main/java/com/workup/users/commands/utils/PasswordHasher.java index 87bebe26..53fc28d3 100644 --- a/services/users/src/main/java/com/workup/users/commands/utils/PasswordHasher.java +++ b/services/users/src/main/java/com/workup/users/commands/utils/PasswordHasher.java @@ -1,13 +1,14 @@ package com.workup.users.commands.utils; -import org.mindrot.jbcrypt.BCrypt; +import com.google.common.hash.Hashing; +import java.nio.charset.StandardCharsets; public class PasswordHasher { public static String hashPassword(String password) { - return BCrypt.hashpw(password, BCrypt.gensalt()); + return Hashing.sha256().hashString(password, StandardCharsets.UTF_8).toString(); } public static boolean checkPassword(String inputPassword, String hashedPassword) { - return BCrypt.checkpw(inputPassword, hashedPassword); + return hashPassword(inputPassword).equals(hashedPassword); } }