public static boolean verify(String signedRequestHex,String stringToSign,PublicKey publicKey) throws DecoderException, InvalidKeyException, SignatureException {
  byte[] signedRequest=Hex.decodeHex(signedRequestHex.toCharArray());
  Signature sig;
  try {
    sig=Signature.getInstance(SHA256_WITH_RSA);
  }
 catch (  NoSuchAlgorithmException e) {
    throw new IllegalArgumentException("An error occurred while getting the signature algorithm",e);
  }
  sig.initVerify(publicKey);
  sig.update(stringToSign.getBytes(StandardCharsets.UTF_8));
  return sig.verify(signedRequest);
}

public static boolean verify ( String signedRequestHex , String stringToSign , PublicKey publicKey ) throws DecoderException , InvalidKeyException , SignatureException { byte [ ] signedRequest = Hex . decodeHex ( signedRequestHex . toCharArray ( ) ) ; Signature sig ; try { sig = Signature . getInstance ( SHA256_WITH_RSA ) ; } catch ( NoSuchAlgorithmException e ) { throw new IllegalArgumentException ( "An error occurred while getting the signature algorithm" , e ) ; } sig . initVerify ( publicKey ) ; sig . update ( stringToSign . getBytes ( StandardCharsets . UTF_8 ) ) ; return sig . verify ( signedRequest ) ; }
verify a signed request using a hex - formatted string , the string to sign , and a certificate ' s public key .
