Skip to content

Commit

Permalink
Updated encryption algo for users.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmad45123 committed May 19, 2024
1 parent be7cdaf commit 1119783
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions services/users/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,9 @@
</dependency>

<dependency>
<groupId>org.mindrot</groupId>
<artifactId>jbcrypt</artifactId>
<version>0.4</version>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 1119783

Please sign in to comment.