Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. public void VerifySig(String path,PublicKey pK) throws NoSuchAlgorithmException, NoSuchProviderException, IOException, SignatureException, InvalidKeyException{
  2.  
  3. Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
  4.  
  5. PublicKey RSAPublicKey = pK;
  6.  
  7. Signature signature = Signature.getInstance("SHA1withRSA", "BC");
  8. //signature.initSign(RSAPrivateKey, new SecureRandom());
  9.  
  10.  
  11. byte[] array = Files.readAllBytes(new File(path).toPath());
  12. signature.update(array);
  13.  
  14. byte[] sigBytes = signature.sign();
  15. signature.initVerify(RSAPublicKey);
  16. signature.update(array);
  17. System.out.println(signature.verify(sigBytes));
  18.  
  19. }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement