Created
August 9, 2019 07:18
-
-
Save AppLoidx/ed5a0a2ef711ab0f1aa00ae20a713770 to your computer and use it in GitHub Desktop.
Hashing util static class using Apache Commons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.apploidxxx.api.util; | |
import org.apache.commons.codec.digest.Md5Crypt; | |
import java.util.Base64; | |
/** | |
* @author Arthur Kupriyanov | |
*/ | |
public class Password { | |
private static final String salt = Base64.getEncoder().encodeToString("someValue".getBytes()); | |
public static String hash(String password){ | |
return Md5Crypt.md5Crypt((password + salt).getBytes()); | |
} | |
private static String hash(String password, String anotherEncryptedPassword){ | |
return Md5Crypt.md5Crypt((password + salt).getBytes(), anotherEncryptedPassword); | |
} | |
public static boolean isEqual(String rawPassword, String hashedPassword){ | |
return hashedPassword.equals(hash(rawPassword, hashedPassword)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment