Package javax.crypto

Examples of javax.crypto.Cipher.update()


            if (serializedData != null) {
                int numBytes;
                byte[] buf = new byte[8192];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                while ((numBytes = serializedData.read(buf)) != -1) {
                    byte[] data = c.update(buf, 0, numBytes);
                    baos.write(data);
                }
                baos.write(c.doFinal());
                encryptedBytes = baos.toByteArray();
            } else {
View Full Code Here


            if (serializedData != null) {
                int numBytes;
                byte[] buf = new byte[8192];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                while ((numBytes = serializedData.read(buf)) != -1) {
                    byte[] data = c.update(buf, 0, numBytes);
                    baos.write(data);
                }
                baos.write(c.doFinal());
                encryptedBytes = baos.toByteArray();
            } else {
View Full Code Here

            Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding");
            SecretKey key = getKeyFromPassphrase(passphrase, iv, 24);
            cipher.init(Cipher.DECRYPT_MODE, key, new IvParameterSpec(iv));

            byte[] plain = new byte[payload.length];
            cipher.update(payload, 0, payload.length, plain, 0);

            return plain;
        } else {
            return payload;
        }
View Full Code Here

        Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding");
        SecretKey key = getKeyFromPassphrase(passphrase, iv, 24);
        cipher.init(Cipher.ENCRYPT_MODE, key, new IvParameterSpec(iv));

        byte[] encrypted = new byte[payload.length];
        cipher.update(payload, 0, payload.length, encrypted, 0);
        setPayload(encrypted);
    }

    /**
     *
 
View Full Code Here

  cipher = createCipher(opmode);
  b = new byte[BUFFER_SIZE];

  while ((n = in.read(b)) > 0) {
      out.write(cipher.update(b, 0, n));
  }
  out.write(cipher.doFinal());
  out.flush();
  in.close();
    }
View Full Code Here

            if (serializedData != null) {
                int numBytes;
                byte[] buf = new byte[8192];
                ByteArrayOutputStream baos = new ByteArrayOutputStream();
                while ((numBytes = serializedData.read(buf)) != -1) {
                    byte[] data = c.update(buf, 0, numBytes);
                    baos.write(data);
                }
                baos.write(c.doFinal());
                encryptedBytes = baos.toByteArray();
            } else {
View Full Code Here

            byte[] output = new byte[size];

            // Then encrypt along with the nonce and the hash code
            byte[] nonce = nextNonce();
            byte[] hash = generateHashCode(nonce, inbytes);
            int index = cipher.update(hash, 0, HASH_CODE_SIZE, output, 0);
            index = cipher.update(nonce, 0, NONCE_SIZE, output, index);
            if (inbytes.length == 0) {
                cipher.doFinal(output, index);
            }
            else {
View Full Code Here

            // Then encrypt along with the nonce and the hash code
            byte[] nonce = nextNonce();
            byte[] hash = generateHashCode(nonce, inbytes);
            int index = cipher.update(hash, 0, HASH_CODE_SIZE, output, 0);
            index = cipher.update(nonce, 0, NONCE_SIZE, output, index);
            if (inbytes.length == 0) {
                cipher.doFinal(output, index);
            }
            else {
                cipher.doFinal(inbytes, 0, inbytes.length, output, index);
View Full Code Here

                }
                boolean updateRequired = keyProps != null && keyProps.getAdditionalData() != null;
                int offset = 0;
                for (; offset + blockSize < bytes.length; offset += blockSize) {
                    byte[] next = !updateRequired ? c.doFinal(bytes, offset, blockSize)
                        : c.update(bytes, offset, blockSize);
                    result = addToResult(result, next);
                }
                if (offset < bytes.length) {
                    result = addToResult(result, c.doFinal(bytes, offset, bytes.length - offset));
                } else {
View Full Code Here

        {
            byte[] bi = secKeyData[0].toByteArray();

            if (bi[0] == 0)
            {
                c1.update(bi, 1, bi.length - 1);
            }
            else
            {
                c1.update(bi);
            }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.