Class: Ciphr::Functions::Bitwise::BinaryTruncBitwise
- Defined in:
- lib/ciphr/functions/bitwise.rb
Instance Attribute Summary
Attributes inherited from Function
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Function
aligned, inherited, #initialize, invertable?, #prepend, #read
Constructor Details
This class inherits a constructor from Ciphr::Functions::Function
Class Method Details
.params ⇒ Object
25 26 27 |
# File 'lib/ciphr/functions/bitwise.rb', line 25 def self.params [:input, :input] end |
.variants ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/ciphr/functions/bitwise.rb', line 17 def self.variants [ ['and-trunc', {:op=>:&}], ['or-trunc', {:op=>:|}], [['xor-trunc'], {:op=>:'^'}] ] end |
Instance Method Details
#apply ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/ciphr/functions/bitwise.rb', line 3 def apply input, = @args Proc.new do keychunk = .read(256) inchunk = input.read(256) if inchunk && keychunk a,b=[inchunk,keychunk].sort_by{|x| x.size} a.bytes.each_with_index.map{|c,i|c.send(@options[:op], b.bytes.to_a[i%b.size])}.pack("c*") else nil end end end |