class Ciphr::Functions::Bitwise::BinaryBitwise
Public Class Methods
params()
click to toggle source
# File lib/ciphr/functions/bitwise.rb, line 54 def self.params [:input, :input] end
variants()
click to toggle source
# File lib/ciphr/functions/bitwise.rb, line 46 def self.variants [ ['and', {:op=>:&}], ['or', {:op=>:|}], [['xor'], {:op=>:'^'}] ] end
Public Instance Methods
apply()
click to toggle source
# File lib/ciphr/functions/bitwise.rb, line 31 def apply input,keyinput = @args keyb, inputb = [keyinput.read.bytes.to_a, input.read.bytes.to_a].sort_by{|a| a.size } Proc.new do if inputb resb = inputb.each_with_index.map{|c,i|c.send(@options[:op], keyb[i%keyb.size])} res = resb.pack("c*") inputb = nil res else nil end end end