private static byte[] sign(PrivateKey key,String data,SignatureAlgorithm algorithm) throws GeneralSecurityException {
  Signature signature=Signature.getInstance(algorithm.getJCAName());
  signature.initSign(key);
  signature.update(data.getBytes());
  return signature.sign();
}

private static byte [ ] sign ( PrivateKey key , String data , SignatureAlgorithm algorithm ) throws GeneralSecurityException { Signature signature = Signature . getInstance ( algorithm . getJCAName ( ) ) ; signature . initSign ( key ) ; signature . update ( data . getBytes ( ) ) ; return signature . sign ( ) ; }
signs the data with the given key and the provided algorithm .
