Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Security
Search Coderanch
Advance search
Google search
Register / Login
Win a copy of
Software Teaming: A Mob Programming, Whole-Team Approach
this week in the
Agile and Other Processes
forum!
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Ron McLeod
Tim Cooke
Liutauras Vilda
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Rob Spoor
Junilu Lacar
Saloon Keepers:
Stephan van Hulst
Tim Holloway
Piet Souris
Carey Brown
Bartenders:
Forum:
Security
problem in encryption of ZIP files.
Bala Raju Mandala
Ranch Hand
Posts: 40
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
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?
Ulf Dittmer
Rancher
Posts: 43045
77
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
How are you doing the encryption/decryption?
Bala Raju Mandala
Ranch Hand
Posts: 40
I like...
posted 14 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I am using AES algorithem.
Key Generator code is: --------------------- KeyGenerator kgen = KeyGenerator.getInstance("AES"); kgen.init(128); //128 bits key = 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); }
[ September 25, 2008: Message edited by: Bala Raju Mandala ]
Don't get me started about those stupid
light bulbs
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
FTP Put a zip file that contains text files in Linux
Create ZIP file from servlet
How to write zip files into another zip file..?
add zip or jars to classpath
how to extract rar or zip files in java?
More...