Skip to content

Commit

Permalink
Update ZipCrypto instructions for 2.x versions.
Browse files Browse the repository at this point in the history
Suggested by @KamilDzierbicki in rubyzip#568.
  • Loading branch information
hainesr committed Feb 24, 2024
1 parent e3c173b commit fd0cf54
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,27 @@ Any attempt to move about in a zip file opened with `Zip::InputStream` could res

Rubyzip supports reading/writing zip files with traditional zip encryption (a.k.a. "ZipCrypto"). AES encryption is not yet supported. It can be used with buffer streams, e.g.:

#### Version 2.x

```ruby
# Writing.
enc = Zip::TraditionalEncrypter.new('password')
buffer = Zip::OutputStream.write_buffer(::StringIO.new(''), enc) do |output|
output.put_next_entry("my_file.txt")
output.write my_data
end

# Reading.
dec = Zip::TraditionalDecrypter.new('password')
Zip::InputStream.open(buffer, 0, dec) do |input|
entry = input.get_next_entry
puts "Contents of '#{entry.name}':"
puts input.read
end
```

#### Version 3.x

```ruby
# Writing.
enc = Zip::TraditionalEncrypter.new('password')
Expand Down

0 comments on commit fd0cf54

Please sign in to comment.