Created
November 27, 2016 12:44
-
-
Save nitincoded/6b4191a7b9f5cd49c13267e66bfb54da to your computer and use it in GitHub Desktop.
com.nitin.EamPwHasher
This file contains hidden or 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.nitin; | |
import java.security.MessageDigest; | |
import org.apache.commons.codec.binary.Base64; | |
public class EamPwHasher { | |
public static String hashedPassword(String aUsername, String aPassword) throws Exception { | |
MessageDigest hasher = MessageDigest.getInstance("SHA-256"); | |
byte[] salt = (aUsername.toUpperCase()+"@#$ABCDEFGHIJKLMNOPQRSTUVWXYZ/(-").substring(0, 32).getBytes("UTF-8"); | |
hasher.update(salt); | |
return "{S2X}" + Base64.encodeBase64String(hasher.digest(aPassword.toUpperCase().getBytes("UTF-8"))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Drop the toUpperCase if you change the config settings to make the password case sensitive.