Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copyright 2012 Jesse Zilstorff
- module Charcoal
- def self.encrypt(stream, key)
- last = key.first
- stream.bytes.with_index.map do |byte, index|
- key.unshift(last = index ^ key.pop ^ last)
- byte ^ last
- end.pack("C*")
- end
- def self.encrypt_blocks(instream, outstream, key)
- buffer = ""
- blksize = instream.stat.blksize
- while instream.read(blksize, buffer)
- outstream.write(encrypt(buffer, key))
- end
- end
- end
- Charcoal.encrypt_blocks(
- File.new(ARGV.first),
- File.new(ARGV.last, IO::CREAT|IO::WRONLY),
- "AS<k-_5\y[K`,~aqQrm~8{rI#lw=T|DI".bytes.to_a
- #"rLUQk!uiq5)<4d|7ZURd9k6H~(Mxtd1@".bytes.to_a
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement