Code example for SecretKeySpec

Methods: getEncoded

0
        return(val);
    } 
 
    public InputStream createInputStream(InputStream is,  Key k) throws EncryptionException {
        try { 
            return createInputStream(is, new SecretKeySpec(k.getEncoded(), k.getAlgorithm()));
        } 
        catch (InvalidKeyException e) {
            throw new EncryptionException("Unable to create decryptor data using key " + k,e);
        } 
        catch (NoSuchAlgorithmException e) {
            throw new EncryptionException("Unable to create decryptor data using key " + k,e);
        } 
        catch (NoSuchPaddingException e) {
            throw new EncryptionException("Unable to create decryptor data using key " + k,e);
        } 
        catch (InvalidAlgorithmParameterException e) {
            throw new EncryptionException("Unable to create decryptor data using key " + k,e);
        } 
        catch (IOException e) {
            throw new EncryptionException("Unable to create decryptor data using key " + k,e);
        } 
	} 
     
    /** 
     * Returns decryption parameters (the Initialization Vector iv and the length of the stream) 
     *  
     * @param sha1Value - identifier of the individual file 
     * @param uidValue- identical to the sha1Value for a simple document; for the series this is  
     *        the name of the series. 
     * @return 
     * @throws IOException 
     */ 
  
 
 
 
    public InputStream createInputStream(InputStream is,  SecretKeySpec key)
			throws IOException, NoSuchAlgorithmException, 
			NoSuchPaddingException, InvalidAlgorithmParameterException, 
			InvalidKeyException { 
         
    	if (key == null){
    		throw new NullPointerException("Null key");
    	} 
     
    	byte[] encodedKey = key.getEncoded();
    	if (encodedKey == null)
    		throw new NullPointerException("Null key; can not decrypt input stream");
    	 
    	 
    	if (isDummyKey(key)){