class Ciphr::Functions::Bitwise::BinaryTruncBitwise
Public Class Methods
params()
click to toggle source
# File lib/ciphr/functions/bitwise.rb, line 25 def self.params [:input, :input] end
variants()
click to toggle source
# File lib/ciphr/functions/bitwise.rb, line 17 def self.variants [ ['and-trunc', {:op=>:&}], ['or-trunc', {:op=>:|}], [['xor-trunc'], {:op=>:'^'}] ] end
Public Instance Methods
apply()
click to toggle source
# File lib/ciphr/functions/bitwise.rb, line 3 def apply input,keyinput = @args Proc.new do keychunk = keyinput.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