def unicipher_cbc(direction,key_str,input_buf,iv)

      method="#{direction.to_s}_cbc_block"
      blocks = input_buf.chunks_of(@block_size_bytes)
      iv   ||= blocks.shift.str
      key    = CryptBuffer(key_str).hex
      
      prev_block=iv.to_crypt_buffer

      strings = blocks.map.with_index do |block,i|
        ctext_block = send(method,key,block,prev_block)
        if direction == :encipher
          prev_block  = ctext_block
        else
          prev_block  = block
        end

        ctext_block.str
      end

      CryptBuffer(strings.join)
    end
def unicipher_cbc(direction,key_str,input_buf,iv)

      method="#{direction.to_s}_cbc_block"
      blocks = input_buf.chunks_of(@block_size_bytes)
      iv   ||= blocks.shift.str
      key    = CryptBuffer(key_str).hex
      
      prev_block=iv.to_crypt_buffer

      strings = blocks.map.with_index do |block,i|
        ctext_block = send(method,key,block,prev_block)
        if direction == :encipher
          prev_block  = ctext_block
        else
          prev_block  = block
        end

        ctext_block.str
      end

      CryptBuffer(strings.join)
    end
this method is used for encipher and decipher since most of the code is identical
 only the value of the previous block and the internal ecb method differs