-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathEmployeeHelper.java
More file actions
34 lines (26 loc) · 905 Bytes
/
EmployeeHelper.java
File metadata and controls
34 lines (26 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package edu.uark.registerapp.commands.employees.helpers;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import org.apache.commons.lang3.StringUtils;
public class EmployeeHelper {
public static String padEmployeeId(final int employeeId) {
final String employeeIdAsString = Integer.toString(employeeId);
return ((employeeIdAsString.length() < EMPLOYEE_ID_MAXIMUM_LENGTH)
? StringUtils.leftPad(
employeeIdAsString,
EMPLOYEE_ID_MAXIMUM_LENGTH,
"0")
: employeeIdAsString);
}
public static byte[] hashPassword(final String password) {
try {
final MessageDigest messageDigest =
MessageDigest.getInstance("SHA-256");
messageDigest.update(password.getBytes());
return messageDigest.digest();
} catch (final NoSuchAlgorithmException e) {
return new byte[0];
}
}
private static final int EMPLOYEE_ID_MAXIMUM_LENGTH = 5;
}