Sha256: fe7e5640f241f00592503bdd8d7c8c66e13593e89683718c65b8d1bb777c3f24

Contents?: true

Size: 1.1 KB

Versions: 61

Compression:

Stored size: 1.1 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',
                 TestHelper.collector(@algorithm_class.encryption_fiber('mykey', f)))
    f = Fiber.new { Fiber.yield('first'); 'second' }
    assert_equal('mykeyfirstsecond',
                 TestHelper.collector(@algorithm_class.decryption_fiber('mykey', f)))
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
hexapdf-0.24.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.23.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.22.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.21.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.21.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.20.4 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.20.3 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.20.2 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.20.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.20.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.19.3 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.19.2 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.19.1 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.19.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.18.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.17.3 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.17.2 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.16.0 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.15.9 test/hexapdf/encryption/test_arc4.rb
hexapdf-0.15.8 test/hexapdf/encryption/test_arc4.rb