Skip to content

Instantly share code, notes, and snippets.

@mechamogera
Created December 19, 2012 12:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mechamogera/4336452 to your computer and use it in GitHub Desktop.
Save mechamogera/4336452 to your computer and use it in GitHub Desktop.
ziprubyの暗号化zip圧縮解凍のテストスクリプト
require 'rubygems'
require 'zipruby'
outdir = "test"
Zip::Archive.open('hoge.zip', Zip::CREATE) do |arc|
arc.add_file('test.txt')
arc.encrypt('password')
end
Zip::Archive.open("hoge.zip") do |arc|
arc.decrypt('password')
arc.num_files.times do |i|
arc.fopen(arc.get_name(i)) do |file|
File.open(File.join(outdir, file.name), "w") do |f|
f.write file.read
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment