Skip to content

Commit 5387505

Browse files
committed
Revert "Changed secret data type from string to bytes."
This reverts commit 725e3ea.
1 parent 725e3ea commit 5387505

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/main/java/com/auth0/jwt/JWTSigner.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
* No support for RSA encryption at present
2727
*/
2828
public class JWTSigner {
29-
private final byte[] secret;
29+
private final String secret;
3030

31-
public JWTSigner(byte[] secret) {
31+
public JWTSigner(String secret) {
3232
this.secret = secret;
3333
}
3434

@@ -216,7 +216,7 @@ private String base64UrlEncode(byte[] str) {
216216
/**
217217
* Switch the signing algorithm based on input, RSA not supported
218218
*/
219-
private static byte[] sign(Algorithm algorithm, String msg, byte[] secret) throws Exception {
219+
private static byte[] sign(Algorithm algorithm, String msg, String secret) throws Exception {
220220
switch (algorithm) {
221221
case HS256:
222222
case HS384:
@@ -233,9 +233,9 @@ private static byte[] sign(Algorithm algorithm, String msg, byte[] secret) throw
233233
/**
234234
* Sign an input string using HMAC and return the encrypted bytes
235235
*/
236-
private static byte[] signHmac(Algorithm algorithm, String msg, byte[] secret) throws Exception {
236+
private static byte[] signHmac(Algorithm algorithm, String msg, String secret) throws Exception {
237237
Mac mac = Mac.getInstance(algorithm.getValue());
238-
mac.init(new SecretKeySpec(secret, algorithm.getValue()));
238+
mac.init(new SecretKeySpec(secret.getBytes(), algorithm.getValue()));
239239
return mac.doFinal(msg.getBytes());
240240
}
241241

0 commit comments

Comments
 (0)