Code example for SecretKey

Methods: getAlgorithm, getEncoded

0
        if (key == null)
        { 
            throw new InvalidKeyException("key parameter is null");
        } 
         
        if (!key.getAlgorithm().equalsIgnoreCase(algName))
        { 
            throw new InvalidKeyException("Key not of type " + algName + ".");
        } 
 
        return new SecretKeySpec(key.getEncoded(), algName);
    } 
 
    /* 
     * classes that inherit from us 
     */ 
     
    static public class PBEKeyFactory 
        extends JCESecretKeyFactory 
    { 
        private boolean forCipher;