I have zipped and protected a file with a password.
Now I need to retrieve the file back with java. So I need to unlock the password and unzip with Java to make a proper connection to the file.
My first Questions is: Does Java unzip and unlock the zipped file on the local drive? (So no point protecting it?).
I have read all about encryption, but really searching for the easiest way here.
This link: http://blog.alutam.com/2009/10/31/reading-password-protected-zip-files-in-java/
My second Question is about the link above: I cannot find the lines where he is pointing to his zipped file on the local drive+ the password he uses to unlock the file (is it hardcoded?)
Thank you
You may want to have a look on Zip4j
Key features:
Create, Add, Extract, Update, Remove files from a Zip file
Read/Write password protected Zip files
Supports AES 128/256 Encryption
Supports Standard Zip Encryption
Supports Zip64 format
Supports Store (No Compression) and Deflate compression method
Create or extract files from Split Zip files (Ex: z01, z02,...zip)
Supports Unicode file names
Progress Monitor
Related
In my project which deals with SAS
we have risk binary files of extension .rskcdesc
I have been looking but not able to find any python Java library which can read it.
I need to automate data checks via Backend process, hence need a way to decode these files.
Any suggestions?
Rohit,
I don't have SAS Risk but SAS has been using zip for some of their files (like EG projects). Try renaming the file extension to .zip and open it. It may be comprised of XML files, similar to EG.
I need to check a 7z file for encryption.
I am using sevenzipjbind and using the property ENCRYPTED, but it seems it involves a lot more steps after that which I am not able to certain.
You can use commons-compress which supports reading encrypted 7zip archives. From the official website:
The ar, arj, cpio, dump, tar, 7z and zip formats are supported as archivers where the zip implementation provides capabilities that go beyond the features found in java.util.zip. As of Commons Compress 1.18 support for the dump and arj formats is read-only - 7z can read most compressed and encrypted archives but only write unencrypted ones. LZMA(2) support in 7z requires XZ for Java as well.
Take a look at SevenZFile class to see if you can use it. Internally SevenZFile reads archive header to check the password.
I am new to encryption process. Can a zip file be encrypted with a given text or can we encrypt the zip by any algorithm like aes, triples aes, blowfish. If there is a process, please guide me with examples and reference.
zip4j, java library to handle Zip files (Open source, Apache License
v2.0).
http://www.lingala.net/zip4j/
Create, Add, Extract, Update, Remove files from a Zip file Read/Write
password protected Zip files Supports AES 128/256 Encryption Supports
Standard Zip Encryption You can download binary, sources and examples.
This topic is likely to solve your issues. I founded also the java.util.zip documentation which might help you.
I also have heard once about 7-zip being linkable into a project, but I don't know if it is possible in java.
Using TrueZIP, is there a way to open and modify an existing ZIP file from a stream (it may of course be outputted using another stream)?
I have code for modifying a ZIP that works perfectly as long as I work on an existing real ZIP file on the file system but I have a requirement that all temporary files need to be encrypted while stored on disk. In most part of our application this is easy to achieve (using CipherOutputStream and CipherInputStream) but I have one function that uses TrueZIP to update an existing ZIP file. This part obviously fails if the file is encrypted.
The ZIP files will be consumed by proprietary applications that do not support encryption so using the encryption that is part of the ZIP specification isn't possible.
The reason we are using TrueZIP is that we need the support for Zip64 (which I know is included in Java 7 but we cannot switch right now).
No, an archive file must be stored in accessible file system to use it with TrueZIP. But you have a number of other options:
TrueZIP uses instances of the IOPoolService interface to manage temporary files. You could provide your own implementation which encrypts all temporary files or maybe even just stores them on the heap (if they are small). Have a look at the TrueZIP Driver FILE to see the reference implementation.
You could use the ParanoidZipRaesDriver to use RAES encrypted ZIP files. This driver ensures that no unencrypted temporary files are used by limiting the number of concurrent threads for writing an archive file to one.
You could use the standard ZIP drivers with FsOutputOption.ENCRYPT to switch on WinZip AES encryption. To ensure that no unencrypted temporary files are used, you could then override the ZipDriver.newOutputSocket method just like the ParanoidZipRaesDriver does.
I have an encrypted ODT (Open Document Text) file and I need to unzip it. ODT is a ZIP file. An encrypted ODT is a normal ZIP file, just some files inside the ZIP are encrypted.
Using ZipFile works okay in a test, but I cannot use ZipFile really because I have a stream in memory, I don't want to work with a file.
Therefore I use ZipInputStream. But using ZipInputStream.getNextEntry() throws the dreadful
only DEFLATED entries can have EXT descriptor
exception.
From what I can understand, it throws on the first encrypted file inside the ZIP package, for example on content.xml. Because OpenOffice has encrypted the xml file, it was probably no point compressing it and it was stored inside the ZIP package uncompressed.
But ZipInputStream seems to have a problem with it and I don't see a way around.
And yes, the encrypted ODT file was created by OpenOffice Writer 3.2.1. And yes, the stock ZipInputStream cannot even enumerate through entries in it.
Anything you can suggest?
You can have a look if it's possible with ODF Toolkit library
The problem has nothing to do with encryption, but with the fact that ZipInputStream does not expect (and does not know how to handle) an EXT descriptor when the associated data was not DEFLATED (i.e. was stored uncompressed, as-is). This may well be a deficiency ("bug") in ZipInputStream, but I am not familiar enough with the zip specs to know one way or another.
An inelegant, even downright ugly workaround is to persist the stream to a temporary file, and then process it as a ZipFile.
(I am the author of ODFind and the "Decrypting ODF Files" document mentioned above.)
Have you stumbled upon what Ringlord did in ODFind to read encrypted ODF files? This ODF document (viewable as HTML here courtesy Google) claims there is simply no way to rely solely on the Java libraries to decrypt OpenOffice.org documents. However, the author explains how one can decrypt the content.xml payload of an ODF file with knowledge of the ODF Manifest, RFC 2989, the PBKDF2Engine in JBoss3 and some original discovery by the author.
Best wishes.
DISCLAIMER: I have no affiliation whatsoever with Ringlord despite every link above points to Ringlord content.