public static byte [ ] signWithSha1RSA ( byte [ ] dataToSign , PrivateKey privateKey ) throws InvalidKeyException { Signature signature ; try { signature = Signature . getInstance ( "SHA1withRSA" ) ; signature . initSign ( privateKey , srand ) ; signature . update ( dataToSign ) ; return signature . sign ( ) ; } catch ( NoSuchAlgorithmException e ) { throw new IllegalStateException ( e ) ; } catch ( SignatureException e ) { throw new IllegalStateException ( e ) ; } }
Signs the data given with the private key given using the SHA1withRSA algorithm provided by bouncy castle .