Problem in ZIP file encryption

Hi Folks,
I am facing a problem while encrypting and decrypting a ZIP file. The result file is corrupted.
If i encrypt .txt and .doc files, i am able to get them in decryption. But problem with ZIP files. What could be the reasone?
I am using AES algorithem.
Key Generator code is:
================
KeyGenerator kgen = KeyGenerator.getInstance("AES");
kgen.init(128); //128 bitskey = kgen.generateKey();
Encryption:
========
Cipher ecipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
//paramSpec is a Initialization Vector
ecipher.init(Cipher.ENCRYPT_MODE, skey, paramSpec);
FileInputStream in = new FileInputStream("c:\\encryption\\Source.zip");
FileOutputStream out = new FileOutputStream("c:\\cipher\\cipher.enc");
OutputStream cout = new CipherOutputStream(out, ecipher);
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {     
cout.write(buf, 0, numRead);
Decryption:
========
Cipher dcipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
dcipher.init(Cipher.DECRYPT_MODE, skey, paramSpec);
FileInputStream fis = new FileInputStream("c:\\cipher\\cipher.enc");
InputStream in = new CipherInputStream(fis, dcipher);
FileOutputStream fos = new FileOutputStream("c:\\encryption\\Result.zip");
int numRead = 0;
while ((numRead = in.read(buf)) >= 0) {    
fos.write(buf, 0, numRead);
}

bala_1404 wrote:
i closed them in the program. i just pasted important lines of my program.You have a program that does not work and you don't know why yet you feel confident enough in your diagnosis to show just the lines where you think the problem lies. I'm betting that you are closing the wrong streams but of course I am guessing since I can't see the code that matters.
Good luck.

Similar Messages

  • Waas caching problem with zip files

    hi,
    When we send same zipped file to branches, waas does not cache that file, without zipping waas caches the file. Is there any restrictions for zip file?

    Hi Muhammed,
    When you say that WAAS is not caching, I guess you mean that the optimization achieved is much lower than without zipping the file. Am I correct?
    If that is the case, then, I'm afraid it's the expected behavior. The cause for this is DRE
    In general terms, the way DRE works is by caching small chunks of a file. Later on, when these chunks are seen again in the file (either in the same connection or subsequent ones), they will not be transferred through the WAN link and instead, a chunk identifier (very small) will be sent. The problem is that all compression algorithms work in a similar way, removing repeating parts of the file to make it smaller.
    The result is that, any file that is encrypted/compressed has almost no repeating patterns in it, and therefore, even though DRE is applied, the reduction ratios are minimal, sometimes even getting to the point of making transfer even slower than without it.
    As a general good practice, if you are using WAAS to optimized your data transfers, make sure that the files you are transferring are neither compressed nor encrypted. This way you will get the maximum optimization ratios out of WAAS.
    I hope this answers your question
    Daniel

  • Problem with ZIP file download

    I try to download a ZIP file from some URL. Everything goes fine, but I never get the entire content of the file (1.79 MB size).
    Here a code snipet:
    byte[] data = new byte[conn.getContentLength()];
    Object obj = conn.getContent();
    java.io.BufferedInputStream bis = (java.io.BufferedInputStream) obj;
    bis.read(data);
    bis.close();
    File f = new File(sPath.toLowerCase());
    FileOutputStream fos = new FileOutputStream(f);
    fos.write(data);
    fos.flush();
    fos.close();
    Any ideas? Thanks in advance.
    Frank

    I think the real problem is that you don't check the return value from read (it's probably less than data.length indicating an incomplete read). Isn't there a readFully somewhere?

  • PKGBUILD problem with zip file

    Hi all,
    I'm trying to build Envy Code R font package. Here is the file:
    pkgname=ttf-envy-code-r
    pkgver=preview7
    _pkgver=PR7
    pkgrel=1
    pkgdesc="Free scalable coding font"
    arch=('i686' 'x86_64')
    url="http://damieng.com/blog/tag/envy-code-r"
    license=('freeware')
    depends=('fontconfig' 'xorg-fonts-encodings' 'xorg-font-utils')
    install=envycoder.install
    source=("http://download.damieng.com/fonts/original/EnvyCodeR-$_pkgver.zip")
    md5sums=('0cce55205f1e8a109021b46c24741257')
    build() {
    cd $srcdir/Envy\ Code\ R\ $_pkgver
    install -D -m644 Read\ Me.txt $pkgdir/usr/share/licenses/$pkgname/readme.txt
    mkdir -p ${startdir}/pkg/usr/share/fonts/TTF
    for i in *.ttf
    do
    mv "$i" $(echo $i | sed -e 's/ //g')
    done
    install -m644 *.ttf ${startdir}/pkg/usr/share/fonts/TTF/ #Skipping what's under VS
    However, 'makepkg' gave this error:  -> bsdtar -x -f EnvyCodeR-PR7.zip
    Envy Code R PR7/Envy Code R Bold.ttf: Write request too large
    Envy Code R PR7/Envy Code R Command Prompt.reg: Write request too large
    Envy Code R PR7/Envy Code R Italic.ttf: Write request too large
    Envy Code R PR7/Envy Code R.ttf: Write request too large
    Envy Code R PR7/Read Me.txt: Write request too large
    Envy Code R PR7/Visual Studio italics-as-bold/Envy Code R VS Italic-as-bold.ttf: Write request too large
    Envy Code R PR7/Visual Studio italics-as-bold/Envy Code R VS.ttf: Write request too large
    bsdtar: Error exit delayed from previous errors.
    I tried bsdtar -x -f with normal zip file and zip file with spaced file name and found no problem. Can anybody explain? Thanks,

    Certain zip files can't be handled by bsdtar; it is explained in more detail in some of the technical writeups of libarchive which processes all files as streams rather than random-access as the 'unzip' program does.
    For zip files that are made in a slightly unorthodox fashion, one can do the following:
    1. Add the zip file to the noextract=() PKGBUILD array
    2. Add 'unzip' as a makedepend
    3. Add as the first lines of your build function:
      cd $srcdir
      unzip <sourcefile>.zip
    4. Continue as normal.

  • Problem adding zip files - is there a size limit?

    Is there a size limit on zip files that are uploaded to the system? I have tried to upload zip files (18Mb and 28Mb) this morning, and on both occasions not all of the zipped information is uploaded.
    Please could you let me know why only half of my files and folder names are being loaded.
    Thanks very much
    Kate

    I had this problem. Portal was installed here with the default
    storage settings on all of the tables, including
    WWDOC_DOCUMENT$. My upload would crash with NO ERRORS. I
    looked at the apache error_log file and saw just what I
    expected: that table was blown out becaus it had reached max
    extents. I moved that table to its own gigantic tablespace and
    sure enough, the load went through fine. You might also be
    interested in what you find in WWDOC_DOCUMENT$. Because even
    after a purge, I found that files that got partially loaded were
    still in that table, even though they weren't visible through
    the portal. So I deleted them, and freed up even more space.
    I'd recommend you move that document table to a separate
    tablespace that the DBA can manage separately, because it's not
    going to grow like a traditional transactional system, so it
    really doesn't belong in the same area.
    Hope this helps,
    Adrian Klingel
    Exaweb

  • Problem with zipping file with chinese chars

    I need to zip a html page which contains some chinese characters, I am able to zip it and create a zip file
    but the problem is when i open the zip file and view the html file it displays junk characters instead
    of chinese characters
    Here is what i am doing
      ByteArrayOutputStream bStream = new ByteArrayOutputStream();
       ZipOutputStream zStream = new ZipOutputStream(bStream);
        ZipEntry zipEntry = new ZipEntry(htmlFilename);
        zStream.putNextEntry(zipEntry);
        ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(
                               new OutputStreamWriter(dataStream,"UTF-8"));
    writer.write(htmlString); //htmlString is the string which contents the html contents which has chinese char
        writer.close();
    zStream.write(dataStream..toByteArray());

    And when you view the unzipped file, are you using something that realizes that you encoded your data using UTF-8? My guess is that you are not.
    PC&#178;

  • Problem downloading ZIP file with Squid-3.0

    Hi,
    I have upgraded my Linux CentOS squid proxy servers to Squid version 3.0. Since then I can not download the following file it just hangs :
    http://download.oracle.com/otn/java/sqldeveloper/sqldeveloper-1.5.5.59.69.zip
    I dont see any error in the squid logs or on my firewall.
    I can however download it on one of the older servers still running Squid version 2.6.
    It is just very strange as I can download ZIP files from any other website with the upgraded servers.
    Any ideas on what might cause this ?
    Thanks
    JHEFER
    Edited by: jhefer on Nov 19, 2009 12:15 AM

    If you have already interested, I found the solution. The problem is that oracle website (and probably others) uses “Vary” field in the header and squid doesn’t support this (by default). You have to download squid sources on http://www.squid-cache.org/Versions/ and compile these with “--enable-http-violations” parameter :
    *./configure ‘--enable-http-violations’ ‘…’ ‘…’*
    make all
    make install
    I hope this solution will be very useful to you.
    Laurent

  • Problem opening .zip files

    I often have difficulty opening .zip files. I received one today. I know the content is images, it is 683MB, and when I click 'open with' the only opton is Photoshop CS5. However, I then get an error message saying Photoshop cannot open this type of file. I have stuffit expander, but that also results in an error message. I know sometimes archive utility (I think that's the name?) will open a zip file, but not in this case.
    Is there a reliable app to that can be used? Any other suggestions?
    JB

    If you want to relocate the Archive Utility to its usual location it resides at,
    Macintosh HD/System/Library/CoreServices
    When moving it you will need to authorise the move with your Admin password. After that, running Repair Permissions would be a worthwhile thing as well.
    If don't wnat to move it that's OK too, as it works for you, but if you want to be fussy, that's where it lives.

  • Strange problems with Zip Files in Captivate/SumTotal

    Ok, this is a weird one. If I publish a 1.2 SCORM course and select the zip folder option, our (horrible) SumTotal 7.6 system has no problems uploading the course. If I publish to a folder or to my desktop and place all the files in the folder and zip the file, it doesn't track as SCORM at all.
    I get the same results on the ADL Test Scorm tracker. When the zip folder is uploaded, it reads as SCORM compliant. When I publish to an upzipped folder and then zip it, I get a ton of XML file not well formed and other xml errors.
    The issue is that I need to make changes to the imsmanifest file to remove the SumTotal Navigation Player and resize the screen properly for the course.
    The zip program we are using is "ZipGenius".
    1.) Has anyone else run into this issue?
    2.) Any ideas on how to fix this so that I can make changes to the imsmanifest file and still upload the course as 1.2 SCORM compliant?
    Thanks,
    Dan

    Kevin,
    At first, I would have thought the LMS doesn't necessarily return the appropriate information for Captivate to send a score (there are several basic calls that are supposed to be sent by an LMS in SCORM to facilitate this).  So, I created a custom HTM file for the Captivate 4 template...  But in re-reading the thread - you are using SumTotal and I believe SumTotal does make these calls...
    For the purposes of anyone else that is using an LMS and not seeing a score in their LMS (and they are using this custom template) - here is a Captivate 4 template file that forces Captivate to send a score to a SCORM LMS (though not necessarily SCORM-compliant LMS - if these calls are ignored):  http://www.learningconsulting.com/Content/Macromedia/Captivate/SumTotal_Captivate4_SCORM_C ustom.zip
    Kevin - I do not necessarily believe this custom template will work for you.  I can send you an entire debug file I've built for helping to track down AICC/SCORM issues - but let's hold off on that, for now.  Can you edit the resulting HTM file of one of your published Captivate file built using the SCORM template I've provided earlier; modify the last line in the method sendTrackingDataToLMS; uncomment out the alert statement (remove the "//").  I'd like to know what is displayed when you close the content window from SumTotal.
    Regards,
    Andrew

  • Working with a zip file

    I'm trying to resolve a problem with a program that involves downloading a .zip file. When you download a .zip file on a MacBook Pro, do you need to "unpack" the file? I have to replace and existing file with the downloaded file. I'm sure I am doing something wrong.

    double clicking usually unpacks the zip file.
    Control click>Compress will zip up a folder/file
    If the archive utility does not unzip, you can try something like StuffitExpander.
    There can be problems with zip files and it may be a source problem beyond your control

  • Suddenly unable to send a Zip file

    Hi there
    I am having a problem sending zip files. It has been working fine before but recently it has not been posible. I always send to the same person, who has been receiving without problems before. The zipped file is 5,2 mb and generated in windows via WMWare Fusion 5. I have no problems if I use Gmail, but in Macmail it is not working.
    Any good ideas?

    So what is happening is the mail app can't connect to the gmail smtp server to send the email. This seems to be a fairly common problem with the built in mail program. One minute it works, can send emails, the next it can't find the smtp server for various email providers like gmail or yahoo or suggests the password is incorrect even though you haven't changed anything.
    From what I read on these forums about the only way to correct this is to complete remove the account for the mail program then recreate it. Make sure you remove all smtp entries for that account also.
    Maybe you should try a different email program that doesn't have these constant glitches that pop up from nowhere.

  • Can't Open (Decompress) any ZIP files all of a sudden!

    Hi
    I've never had problems opening Zip files until a couple of days ago.
    All of a sudden I can't open Zip files from 2 different sources.
    I've tried downloading them in Safari and Firefox.
    I've tried the built in expander and I've tried Stuffit (latest version) and The Unarchiver.
    I keep getting error messages, usually saying the data is corrupted or that it was compressed with an unknown method.
    I got the original file re-sent to me several times (a purchase from a consumer website) with constantly the same result.
    Then today I received a different Zip file from a completely different source with the same result.
    My computer is up to date with all the latest Apple software updates.
    I've tried repairing disc permissions.
    Anyone know of this issue or have any ideas how to fix it?
    Thanks.

    To The Apple Discussion Boards!
    "I've tried repairing disc permissions."
    Did you restart your computer afterwards? If so, download a "zip" file. In the window that pops up, make sure *"Open With"* is selected. Make sure Stuffit Expander is selected or another utility that you want to open all your "zip" files.
    Option: Select +"Do this automatically for files like this from now on."+
    Click the "OK" button.

  • .001 Zip file won't decompress

    I'm having problems downloading zip files. They're actually zip files broken into parts - and inevitably the first of them will not decompress. The system goes through the whole download, and then just freeze up on the Decompression stage. Sometimes it will try to decompress as long as I am willing to let it try and other times I get a decompression failed message. This only happens with the file with a .001 associated with it...
    Anybody have any idea why this is happening?

    Are you using Stuffit Expander?

  • Getting access to encrypted zip files

    hey folks!
    has anyone of you successfully decrypted a password-protected zip file with pure java code?
    if so, please give me some advice or maby some sample code that I can figure out how it works.
    thanks

    sorry, I think I didn't express myself the right way.
    the problem is the following:
    a zip file is created with winzip and is also encrypted with it. this zip file is the input for the tool that I write. my tool should now be able to decrypt and uncompress all the encrypted files in the zip file.
    as far as I know winzip uses different encryption algorithms, so I have no idea where to start.
    I have already read about this bouncy castle stuff but didn't bring my any further

  • Download Adobe Reader past network firewall AV block of zipped and encrypted files?

    I'm having a problem downloading Adobe Reader because our Sonicwall AV settings apparently don't allow zipped and encrypted files into the network.
    I 'd rather not change firewall settings if there is another way to get this done. Thanks...anyone?

    Does that also happen if you download the offline installer from http://get.adobe.com/reader/enterprise/

Maybe you are looking for

  • Midi doesn't play correctly with plugin

    I cannot get midi to play correctly in applets using java plugin (of any version). It does not stay "synced" when it is played. It does work with the appletviewer though. Not even the example in the java tutorial/sound is played correctly. Is there a

  • ATI HD 6000 / 7000 series support in CS6?

    Hey all, I've been planning on snagging a GTX 570 for a while, for my upcoming use w/ Adobe Premiere. Are ATI cards being supported more w/ CS6? I may have to rethink my purchase if they are, since it appears that some of the ATI cards offer better b

  • Screen Captures shrinking in Mail

    I use the feature a lot, taking snap of a portion of the screen, and dropping it in an email to send to someone, but recently whilst the screen capture is fine, when its dropped in an email, it shrinks! To to point where its unreadable. Dropping the

  • HT201210 lost all data and apps when i update ios 6.could i have them back?

    lost all data and apps when i update ios 6.could i have them back?

  • Email Sync - Only on Request

    Hi, I recently did Enterprise Activation and I am able to receive work emails on my device. I have also configured to receive my personal (gmail & yahoomail) emails on the device. However, I do not want them to automatically come in when I'm already