Code example for Key

Methods: getAlgorithm

0
     * Key object's getAlgorithm method. 
     * @param key The key that will be used to perform the encryption. 
     */ 
    public 
    Encryption createEncryption(Key key) throws NoSuchAlgorithmException{
        String algorithm = key.getAlgorithm();
        if ("DES".equals(algorithm))
          return new DESEncryption(key);
        if ("RSA".equals(algorithm))
          return new RSAEncryption(key);
        throw new NoSuchAlgorithmException(algorithm);
    } // createEncryption(Key) 
} // class EncryptionFactory