Created
April 7, 2010 15:04
-
-
Save koichiro/358980 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'java' | |
import java.io.BufferedInputStream | |
import java.io.BufferedOutputStream | |
import java.io.FileInputStream | |
import java.io.FileNotFoundException | |
import java.io.FileOutputStream | |
import java.util.zip.ZipEntry | |
import java.util.zip.ZipOutputStream | |
# Create Plane Zip file | |
zip = ZipOutputStream.new(BufferedOutputStream.new(FileOutputStream.new("arc.zip"))) | |
filename = "test1.txt" | |
file = BufferedInputStream.new(FileInputStream.new(filename)) | |
zip.put_next_entry(ZipEntry.new(java.io.File.new(filename).get_name)) | |
data = nil | |
while ((data = file.read()) != -1) | |
zip.write(data) | |
end | |
file.close | |
zip.close_entry | |
zip.close | |
# Encrypted Zip | |
# Use ZipCloak | |
# http://www.ne.jp/asahi/hishidama/home/tech/soft/java/zip.html | |
import Java::jp.hishidama.zip.ZipCloak | |
plane_zip = java.io.File.new("arc.zip") | |
crypt_zip = java.io.File.new("cryptarc.zip") | |
password = "password" | |
czip = ZipCloak.new(plane_zip) | |
czip.encrypt(crypt_zip, password.to_java_bytes) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment