Code example for Key

Methods: getAlgorithm

0
                    + " unusable", e);
        } 
    } 
 
    protected String signatureAlgorithm(String hashAlgorithm, Key key) throws InvalidKeyException {
        String keyAlgo = key.getAlgorithm();
        if ("RSA".equals(keyAlgo))
            return hashAlgorithm + "withRSA";
        if ("DSA".equals(keyAlgo))
            return hashAlgorithm + "withDSA";
        if ("EC".equals(keyAlgo) || "ECDSA".equals(keyAlgo))
            return hashAlgorithm + "withECDSA";
 
        throw new InvalidKeyException("signing with key algorithm=" + keyAlgo + " not implemented");
    } 
}