Skip to content

Instantly share code, notes, and snippets.

@lmars
Created January 23, 2013 10:22
Show Gist options
  • Save lmars/4604085 to your computer and use it in GitHub Desktop.
Save lmars/4604085 to your computer and use it in GitHub Desktop.
Create a CSV in memory then add it to an encrypted zip file
require 'zipruby'
require 'csv'
csv = CSV.generate do |csv|
csv << ['i', '2i']
1.upto(10) do |i|
csv << [i, i*2]
end
end
Zip::Archive.open('encrypted_csv.zip', Zip::CREATE) do |zip|
zip.add_buffer('nums.csv', csv)
zip.encrypt 'password'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment