Code example for PrivateKey

Methods: getAlgorithm

     * @return the computed signature value 
     * @throws SecurityException thrown if the signature computation results in an error 
    public static byte[] sign(PrivateKey signingKey, String jcaAlgorithmID, byte[] input) throws SecurityException {
        log.debug("Computing signature over input using private key of type {} and JCA algorithm ID {}", signingKey
                .getAlgorithm(), jcaAlgorithmID);
        try { 
            Signature signature = Signature.getInstance(jcaAlgorithmID);
            byte[] rawSignature = signature.sign();
            log.debug("Computed signature: {}", new String(Hex.encode(rawSignature)));
            return rawSignature;
        } catch (GeneralSecurityException e) {
            log.error("Error during signature generation", e);
            throw new SecurityException("Error during signature generation", e);
Contextual code suggestions in your IDE  Get Codota for Java