Sha256: bacfc577e0a1ed569b6443d8e057e7e30fcaeadbb2f26898a226cc09f06a5bee

Contents?: true

Size: 1.08 KB

Versions: 35

Compression:

Stored size: 1.08 KB

Contents

# -*- encoding: utf-8 -*-

require_relative 'common'
require 'hexapdf/encryption/arc4'

describe HexaPDF::Encryption::ARC4 do
  include EncryptionAlgorithmInterfaceTests

  before do
    @algorithm_class = Class.new do
      prepend HexaPDF::Encryption::ARC4

      def initialize(key)
        @data = key
      end

      def process(data)
        raise if data.empty?
        result = @data << data
        @data = ''
        result
      end
    end
  end

  it "correctly uses klass.encrypt and klass.decrypt" do
    assert_equal('mykeydata', @algorithm_class.encrypt('mykey', 'data'))
    assert_equal('mykeydata', @algorithm_class.decrypt('mykey', 'data'))
  end

  it "correctly uses klass.encryption_fiber and klass.decryption_fiber" do
    f = Fiber.new { Fiber.yield('first'); Fiber.yield(''); 'second' }
    assert_equal('mykeyfirstsecond',
                 collector(@algorithm_class.encryption_fiber('mykey', f)))
    f = Fiber.new { Fiber.yield('first'); 'second' }
    assert_equal('mykeyfirstsecond',
                 collector(@algorithm_class.decryption_fiber('mykey', f)))
  end
end

Version data entries

35 entries across 35 versions & 1 rubygems

Version Path
hexapdf-1.0.2 test/hexapdf/encryption/test_arc4.rb
hexapdf-1.0.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-1.0.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.47.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.46.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.45.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.44.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.41.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.40.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.39.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.39.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.38.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.37.2 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.37.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.37.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.36.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.35.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.35.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.34.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.34.0 test/hexapdf/encryption/test_arc4.rb