示例#1
0
        private ZipEntrySource fileToSource(FileInfo tmpFile, CipherAlgorithm cipherAlgorithm, byte[] keyBytes, byte[] ivBytes)
        {
            SecretKeySpec skeySpec = new SecretKeySpec(keyBytes, cipherAlgorithm.jceId);
            Cipher        ciDec    = CryptoFunctions.GetCipher(skeySpec, cipherAlgorithm, ChainingMode.cbc, ivBytes, Cipher.DECRYPT_MODE, "PKCS5PAdding");
            ZipFile       zf       = new ZipFile(tmpFile.FullName);

            return(new AesZipFileZipEntrySource(zf, ciDec));
        }
示例#2
0
        private void CopyToFile(InputStream is1, FileInfo tmpFile, CipherAlgorithm cipherAlgorithm, byte[] keyBytes, byte[] ivBytes)
        {
            SecretKeySpec skeySpec = new SecretKeySpec(keyBytes, cipherAlgorithm.jceId);
            Cipher        ciEnc    = CryptoFunctions.GetCipher(skeySpec, cipherAlgorithm, ChainingMode.cbc, ivBytes, Cipher.ENCRYPT_MODE, "PKCS5PAdding");

            ZipInputStream zis = new ZipInputStream(is1);

            //FileOutputStream fos = new FileOutputStream(tmpFile);
            //ZipOutputStream zos = new ZipOutputStream(fos);

            //ZipEntry ze;
            //while ((ze = zis.NextEntry) != null)
            //{
            //    // the cipher output stream pads the data, therefore we can't reuse the ZipEntry with Set sizes
            //    // as those will be validated upon close()
            //    ZipEntry zeNew = new ZipEntry(ze.Name);
            //    zeNew.Comment = (/*setter*/ze.Comment);
            //    zeNew.Extra = (/*setter*/ze.Extra);
            //    zeNew.Time = (/*setter*/ze.Time);
            //    // zeNew.Method=(/*setter*/ze.Method);
            //    zos.PutNextEntry(zeNew);
            //    FilterOutputStream fos2 = new FilterOutputStream(zos)
            //    {
            //        // don't close underlying ZipOutputStream
            //        public void close() { }
            //};
            //CipherOutputStream cos = new CipherOutputStream(fos2, ciEnc);
            //    IOUtils.Copy(zis, cos);
            //    cos.Close();
            //    fos2.Close();
            //    zos.CloseEntry();
            //    zis.CloseEntry();
            //}
            //zos.Close();
            //fos.Close();
            //zis.Close();
            throw new NotImplementedException();
        }