Class: BlockCipherKit::PassthruScheme
Instance Method Summary
collapse
Methods inherited from BaseScheme
#decrypt_range, #read_copy_stream_via_cipher, #write_copy_stream_via_cipher
Constructor Details
Returns a new instance of PassthruScheme.
2
3
|
# File 'lib/block_cipher_kit/passthru_scheme.rb', line 2
def initialize(...)
end
|
Instance Method Details
#streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil, &blk) ⇒ Object
5
6
7
8
|
# File 'lib/block_cipher_kit/passthru_scheme.rb', line 5
def streaming_decrypt(from_ciphertext_io:, into_plaintext_io: nil, &blk)
w = into_plaintext_io || BlockCipherKit::BlockWritable.new(&blk)
IO.copy_stream(from_ciphertext_io, w)
end
|
#streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil, &blk) ⇒ Object
20
21
22
23
24
25
|
# File 'lib/block_cipher_kit/passthru_scheme.rb', line 20
def streaming_decrypt_range(from_ciphertext_io:, range:, into_plaintext_io: nil, &blk)
from_ciphertext_io.seek(from_ciphertext_io.pos + range.begin)
n_bytes = range.end - range.begin + 1
w = BlockCipherKit::BlockWritable.new(into_plaintext_io, &blk)
w.write(from_ciphertext_io.read(n_bytes))
end
|
#streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil, &blk) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/block_cipher_kit/passthru_scheme.rb', line 10
def streaming_encrypt(into_ciphertext_io:, from_plaintext_io: nil, &blk)
if from_plaintext_io && !blk
IO.copy_stream(from_plaintext_io, into_ciphertext_io)
elsif blk
blk.call(into_ciphertext_io)
else
raise ArgumentError
end
end
|