public static boolean verify(PublicKey publicKey,byte[] sig,ByteBuffer data) throws InvalidKeyException, SignatureException {
  int oldPos=data.position();
  Signature signature=null;
  try {
    signature=Signature.getInstance("SHA1withRSA");
    signature.initVerify(publicKey);
    signature.update(data);
    boolean verify=signature.verify(sig);
    return verify;
  }
 catch (  NoSuchAlgorithmException e) {
  }
 finally {
    data.position(oldPos);
  }
  return false;
}

public static boolean verify ( PublicKey publicKey , byte [ ] sig , ByteBuffer data ) throws InvalidKeyException , SignatureException { int oldPos = data . position ( ) ; Signature signature = null ; try { signature = Signature . getInstance ( "SHA1withRSA" ) ; signature . initVerify ( publicKey ) ; signature . update ( data ) ; boolean verify = signature . verify ( sig ) ; return verify ; } catch ( NoSuchAlgorithmException e ) { } finally { data . position ( oldPos ) ; } return false ; }
verify the signature of a file
