Skip to content

Commit f3fc5f5

Browse files
Update ValidateUsingHmacService.java
Signed-off-by: CassandraLoewen <37552114+CassandraLoewen@users.noreply.github.com>
1 parent 0a0d950 commit f3fc5f5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/main/java/com/docusign/controller/connect/services/ValidateUsingHmacService.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010

1111
public final class ValidateUsingHmacService {
1212
public static String computeHash(String secret, byte[] payload)
13-
throws InvalidKeyException, NoSuchAlgorithmException {
13+
throws InvalidKeyException, NoSuchAlgorithmException, UnsupportedEncodingException {
1414
String digest = "HmacSHA256";
1515
Mac mac = Mac.getInstance(digest);
16-
mac.init(new SecretKeySpec(secret.getBytes(), digest));
17-
String base64Hash = new String(Base64.getEncoder().encode(mac.doFinal(payload)));
18-
return base64Hash;
16+
mac.init(new SecretKeySpec(secret.getBytes("UTF-8"), digest));
17+
return Base64.getEncoder().encodeToString(mac.doFinal(payload));
1918
}
2019

2120
public static boolean isValid(String secret, byte[] payload, String verify)

0 commit comments

Comments
 (0)