class CryptoToolchain::BlackBoxes::AesCtrEditor
Attributes
ciphertext[R]
key[R]
nonce[R]
plaintext[R]
Public Class Methods
new(plaintext, key: Random.new.bytes(16), nonce: rand(0..0x0000FF))
click to toggle source
# File lib/crypto_toolchain/black_boxes/aes_ctr_editor.rb, line 4 def initialize(plaintext, key: Random.new.bytes(16), nonce: rand(0..0x0000FF)) @plaintext = plaintext @key = key @nonce = nonce @ciphertext = plaintext.encrypt_ctr(key: key, nonce: nonce) end
Public Instance Methods
edit(offset: ,with: )
click to toggle source
Offset is in bytes Does not mutate @ciphetext or @plaintext
# File lib/crypto_toolchain/black_boxes/aes_ctr_editor.rb, line 13 def edit(offset: ,with: ) previous = ciphertext[0...offset] after = ciphertext[(offset + with.bytesize)..-1] edited = with.encrypt_ctr(nonce: nonce, key: key, start_counter: offset) previous + edited + after end