Package javax.crypto

Examples of javax.crypto.CipherInputStream


     */
    public CipherInputStream encrypt(InputStream is) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException
    {
        Cipher cipher = initEncryptModeCipher();
        return new CipherInputStream(is, cipher);
    }
View Full Code Here


     */
    public CipherInputStream decrypt(InputStream is) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException
    {
        Cipher cipher = initDecryptModeCipher();
        return new CipherInputStream(is, cipher);
    }
View Full Code Here

        cipher.init(Cipher.ENCRYPT_MODE, this.key, this.algParamSpec);
        transferFileData(inputFile, outputFile, cipher);
    }
   
    protected void transferFileData(File inputFile, File outputFile, Cipher cipher) throws IOException {
        InputStream is = new CipherInputStream(new BufferedInputStream(new FileInputStream(inputFile)), cipher);
        OutputStream os = new BufferedOutputStream(new FileOutputStream(outputFile));
        byte[] buffer = new byte[16384];
        int read = -1;
        while ((read = is.read(buffer)) != -1) {
            os.write(buffer, 0, read);
        }
        os.close();
        is.close();       
    }
View Full Code Here

     */
    public CipherInputStream encrypt(InputStream is) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException
    {
        Cipher cipher = initEncryptModeCipher();
        return new CipherInputStream(is, cipher);
    }
View Full Code Here

     */
    public CipherInputStream decrypt(InputStream is) throws InvalidKeyException,
        InvalidAlgorithmParameterException, NoSuchAlgorithmException, NoSuchPaddingException
    {
        Cipher cipher = initDecryptModeCipher();
        return new CipherInputStream(is, cipher);
    }
View Full Code Here

        } else {
            try {
                InputStream fileInputStream = new TransferableFileInputStream(tempFile);
                streamList.add(fileInputStream);
                if (cipherTransformation != null) {
                    fileInputStream = new CipherInputStream(fileInputStream, ciphers.getDecryptor()) {
                        boolean closed;
                        public void close() throws IOException {
                            if (!closed) {
                                super.close();
                                closed = true;
View Full Code Here

    }

    private InputStream createInputStream(File file) throws IOException {
        InputStream in = new FileInputStream(file);
        if (cipherTransformation != null) {
            in = new CipherInputStream(in, ciphers.getDecryptor()) {
                boolean closed;
                public void close() throws IOException {
                    if (!closed) {
                        super.close();
                        closed = true;
View Full Code Here

        desCipher.init(Cipher.DECRYPT_MODE, secretKey);

        byte[] cypherBytes = Base64.decode(data);

        ByteArrayInputStream bis = new ByteArrayInputStream(cypherBytes);
        CipherInputStream cis = new CipherInputStream(bis, desCipher);

        StringBuilder sb = new StringBuilder();

        while (true) {
            int b = cis.read();
            if (b == -1)
                break;
            sb.append((char) b);
        }

        cis.close();

        if (sb.length() < LONG_SIZE_IN_BYTES +1)
            throw new BitronixRuntimeException("invalid crypted password '" + data + "'");

        return sb.substring(LONG_SIZE_IN_BYTES);
View Full Code Here

                   
                    final SecretKey aesKey = new SecretKeySpec(aesKeyBytes, "AES");
                    try {
                        final Cipher cipher = Cipher.getInstance("AES/CBC/NoPadding");
                        cipher.init(Cipher.DECRYPT_MODE, aesKey, new IvParameterSpec(iv));
                        cipherInputStream = new CipherInputStream(in, cipher);
                        isInitialized = true;
                        return cipherInputStream;
                    } catch (GeneralSecurityException generalSecurityException) {
                        IOException ioe = new IOException("Decryption error " +
                                "(do you have the JCE Unlimited Strength Jurisdiction Policy Files installed?)");
View Full Code Here

    @Override
    InputStream decrypt(final InputStream in) throws IOException {
      try {
        final Cipher c = Cipher.getInstance(algorithmName);
        c.init(Cipher.DECRYPT_MODE, skey, aspec);
        return new CipherInputStream(in, c);
      } catch (NoSuchAlgorithmException e) {
        throw error(e);
      } catch (NoSuchPaddingException e) {
        throw error(e);
      } catch (InvalidKeyException e) {
View Full Code Here

TOP

Related Classes of javax.crypto.CipherInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.