Code example for Key

Methods: getAlgorithm

     * Key object's getAlgorithm method. 
     * @param key The key that will be used to perform the encryption. 
    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 
Stop searching for code, let great code find you!  Add Codota to your java IDE