Skip to content

Instantly share code, notes, and snippets.

@krbullock
Created December 23, 2009 04:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krbullock/262302 to your computer and use it in GitHub Desktop.
Save krbullock/262302 to your computer and use it in GitHub Desktop.
require 'bindata'
module BlockSizeCalculator
def ciphertext_block_size(block_size)
block_size / CipherBlockSize +
(0 == block_size % CipherBlockSize ? 0 : 1) * CipherBlockSize +
CipherBlockSize
end
end
class ChrisPalmer < BinData::Record
include BlockSizeCalculator
uint32 :block_size
string :data, :read_length => lambda { ciphertext_block_size(block_size) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment