Use java.util Hex and Base64 codecs

This commit is contained in:
Chris Eager
2023-02-06 12:16:59 -06:00
committed by GitHub
parent 3bbab0027b
commit 358a286523
27 changed files with 118 additions and 250 deletions

View File

@@ -17,10 +17,10 @@ import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.PKCS8EncodedKeySpec;
import java.util.Base64;
import java.util.HexFormat;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
import org.apache.commons.codec.binary.Hex;
public class CanonicalRequestSigner {
@@ -52,7 +52,7 @@ public class CanonicalRequestSigner {
throw new AssertionError(e);
}
sha256.update(canonicalRequest.getCanonicalRequest().getBytes(StandardCharsets.UTF_8));
result.append(Hex.encodeHex(sha256.digest()));
result.append(HexFormat.of().formatHex(sha256.digest()));
return result.toString();
}
@@ -67,7 +67,7 @@ public class CanonicalRequestSigner {
} catch (NoSuchAlgorithmException | InvalidKeyException | SignatureException e) {
throw new AssertionError(e);
}
return Hex.encodeHexString(signature);
return HexFormat.of().formatHex(signature);
}
private static PrivateKey initializeRsaSigningKey(String rsaSigningKey) throws IOException, InvalidKeyException, InvalidKeySpecException {