Feature: Labelprint für Kistenetiketten hinzugefügt
This commit is contained in:
296
vendor/tecnickcom/tc-lib-pdf-encrypt/test/EncryptTest.php
vendored
Normal file
296
vendor/tecnickcom/tc-lib-pdf-encrypt/test/EncryptTest.php
vendored
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* EncryptTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*
|
||||
* This file is part of tc-lib-pdf-encrypt software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* Encrypt Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*/
|
||||
class EncryptTest extends TestUtil
|
||||
{
|
||||
public function testEncryptException(): void
|
||||
{
|
||||
$this->bcExpectException('\\' . \Com\Tecnick\Pdf\Encrypt\Exception::class);
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'));
|
||||
$encrypt->encrypt('WRONG');
|
||||
}
|
||||
|
||||
public function testEncryptModeException(): void
|
||||
{
|
||||
$this->bcExpectException('\\' . \Com\Tecnick\Pdf\Encrypt\Exception::class);
|
||||
new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 4);
|
||||
}
|
||||
|
||||
public function testEncryptThree(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(
|
||||
true,
|
||||
md5('file_id'),
|
||||
3,
|
||||
['print'],
|
||||
'alpha',
|
||||
'beta'
|
||||
);
|
||||
$result = $encrypt->encrypt(3, 'alpha');
|
||||
$this->assertEquals(32, strlen($result));
|
||||
}
|
||||
|
||||
public function testEncryptPubThree(): void
|
||||
{
|
||||
$pubkeys = [[
|
||||
'c' => __DIR__ . '/data/cert.pem',
|
||||
'p' => ['print'],
|
||||
]];
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(
|
||||
true,
|
||||
md5('file_id'),
|
||||
3,
|
||||
['print'],
|
||||
'alpha',
|
||||
'beta',
|
||||
$pubkeys
|
||||
);
|
||||
$result = $encrypt->encrypt(3, 'alpha');
|
||||
$this->assertEquals(32, strlen($result));
|
||||
}
|
||||
|
||||
public function testEncryptPubNoP(): void
|
||||
{
|
||||
$pubkeys = [[
|
||||
'c' => __DIR__ . '/data/cert.pem',
|
||||
'p' => ['print'],
|
||||
]];
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(
|
||||
true,
|
||||
md5('file_id'),
|
||||
3,
|
||||
['print'],
|
||||
'alpha',
|
||||
'beta',
|
||||
$pubkeys
|
||||
);
|
||||
$result = $encrypt->encrypt(3, 'alpha');
|
||||
$this->assertEquals(32, strlen($result));
|
||||
}
|
||||
|
||||
public function testEncryptPubException(): void
|
||||
{
|
||||
$this->bcExpectException('\\' . \Com\Tecnick\Pdf\Encrypt\Exception::class);
|
||||
new \Com\Tecnick\Pdf\Encrypt\Encrypt(
|
||||
true,
|
||||
md5('file_id'),
|
||||
3,
|
||||
['print'],
|
||||
'alpha',
|
||||
'beta',
|
||||
[[
|
||||
'c' => __FILE__,
|
||||
'p' => ['print'],
|
||||
]]
|
||||
);
|
||||
}
|
||||
|
||||
public function testEncryptModZeroPub(): void
|
||||
{
|
||||
error_reporting(E_ALL); // DEBUG
|
||||
$pubkeys = [[
|
||||
'c' => __DIR__ . '/data/cert.pem',
|
||||
'p' => ['print'],
|
||||
]];
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(
|
||||
true,
|
||||
md5('file_id'),
|
||||
0,
|
||||
['print'],
|
||||
'alpha',
|
||||
'beta',
|
||||
$pubkeys
|
||||
);
|
||||
$result = $encrypt->encrypt(1, 'alpha');
|
||||
// Check for "error:0308010C:digital envelope routines::unsupported" when using OpenSSL 3.
|
||||
// var_dump(openssl_error_string());
|
||||
$this->assertEquals(5, strlen($result));
|
||||
}
|
||||
|
||||
public function testGetEncryptionData(): void
|
||||
{
|
||||
$permissions = ['print'];
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 0, $permissions, 'alpha', 'beta');
|
||||
$result = $encrypt->getEncryptionData();
|
||||
$this->assertEquals('fc93f6b8ab2f4ffb06cf6676f570fc26', md5(serialize($result)));
|
||||
$this->assertEquals(2_147_422_008, $result['protection']);
|
||||
$this->assertEquals(1, $result['V']);
|
||||
$this->assertEquals(40, $result['Length']);
|
||||
$this->assertEquals('V2', $result['CF']['CFM']);
|
||||
}
|
||||
|
||||
public function testGetObjectKey(): void
|
||||
{
|
||||
$permissions = ['print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'];
|
||||
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 2, $permissions, 'alpha', 'beta');
|
||||
$result = $encrypt->getObjectKey(123);
|
||||
$this->assertEquals('93879594941619c98047c404192b977d', bin2hex($result));
|
||||
}
|
||||
|
||||
public function testGetUserPermissionCode(): void
|
||||
{
|
||||
$permissions = [
|
||||
'owner',
|
||||
'print',
|
||||
'modify',
|
||||
'copy',
|
||||
'annot-forms',
|
||||
'fill-forms',
|
||||
'extract',
|
||||
'assemble',
|
||||
'print-high',
|
||||
];
|
||||
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
$result = $encrypt->getUserPermissionCode($permissions, 0);
|
||||
$this->assertEquals(2_147_421_954, $result);
|
||||
}
|
||||
|
||||
public function testConvertHexStringToString(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
|
||||
$result = $encrypt->convertHexStringToString('');
|
||||
$this->assertEquals('', $result);
|
||||
|
||||
$result = $encrypt->convertHexStringToString('68656c6c6f20776f726c64');
|
||||
$this->assertEquals('hello world', $result);
|
||||
|
||||
$result = $encrypt->convertHexStringToString('68656c6c6f20776f726c642');
|
||||
$this->assertEquals('hello world ', $result);
|
||||
}
|
||||
|
||||
public function testConvertStringToHexString(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
|
||||
$result = $encrypt->convertStringToHexString('');
|
||||
$this->assertEquals('', $result);
|
||||
|
||||
$result = $encrypt->convertStringToHexString('hello world');
|
||||
$this->assertEquals('68656c6c6f20776f726c64', $result);
|
||||
}
|
||||
|
||||
public function testEncodeNameObject(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
|
||||
$result = $encrypt->encodeNameObject('');
|
||||
$this->assertEquals('', $result);
|
||||
|
||||
$result = $encrypt->encodeNameObject('059akzAKZ#_=-');
|
||||
$this->assertEquals('059akzAKZ#_=-', $result);
|
||||
|
||||
$result = $encrypt->encodeNameObject('059[]{}+~*akzAKZ#_=-');
|
||||
$this->assertEquals('059#5B#5D#7B#7D#2B#7E#2AakzAKZ#_=-', $result);
|
||||
}
|
||||
|
||||
public function testEscapeString(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
|
||||
$result = $encrypt->escapeString('');
|
||||
$this->assertEquals('', $result);
|
||||
|
||||
$result = $encrypt->escapeString('hello world');
|
||||
$this->assertEquals('hello world', $result);
|
||||
|
||||
$result = $encrypt->escapeString('(hello world) slash \\' . chr(13));
|
||||
$this->assertEquals('\\(hello world\\) slash \\\\\r', $result);
|
||||
}
|
||||
|
||||
public function testEncryptStringDisabled(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
|
||||
$result = $encrypt->encryptString('');
|
||||
$this->assertEquals('', $result);
|
||||
|
||||
$result = $encrypt->encryptString('hello world');
|
||||
$this->assertEquals('hello world', $result);
|
||||
|
||||
$result = $encrypt->encryptString('(hello world) slash \\' . chr(13) . chr(250));
|
||||
$this->assertEquals('(hello world) slash \\' . chr(13) . chr(250), $result);
|
||||
}
|
||||
|
||||
public function testEncryptStringEnabled(): void
|
||||
{
|
||||
$permissions = ['print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'];
|
||||
|
||||
$enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 0, $permissions, 'alpha');
|
||||
$result = $enc->encryptString('(hello world) slash \\' . chr(13));
|
||||
$this->assertEquals('728cc693be1e4c1fb6b7e7b2a34644ad', md5($result));
|
||||
|
||||
$enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 1, $permissions, 'alpha', 'beta');
|
||||
$result = $enc->encryptString('(hello world) slash \\' . chr(13));
|
||||
$this->assertEquals('258ad774ddeec21b3b439a720df18e0d', md5($result));
|
||||
}
|
||||
|
||||
public function testEscapeDataStringDisabled(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt();
|
||||
|
||||
$result = $encrypt->escapeDataString('');
|
||||
$this->assertEquals('()', $result);
|
||||
|
||||
$result = $encrypt->escapeDataString('hello world');
|
||||
$this->assertEquals('(hello world)', $result);
|
||||
|
||||
$result = $encrypt->escapeDataString('(hello world) slash \\' . chr(13));
|
||||
$this->assertEquals('(\\(hello world\\) slash \\\\\r)', $result);
|
||||
}
|
||||
|
||||
public function testEscapeDataStringEnabled(): void
|
||||
{
|
||||
$permissions = ['print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'];
|
||||
|
||||
$enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 0, $permissions, 'alpha');
|
||||
$result = $enc->escapeDataString('(hello world) slash \\' . chr(13));
|
||||
$this->assertEquals('24f60765c1c07a44fc3c9b44d2f55dbc', md5($result));
|
||||
|
||||
$enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 1, $permissions, 'alpha', 'beta');
|
||||
$result = $enc->escapeDataString('(hello world) slash \\' . chr(13));
|
||||
$this->assertEquals('ebc28272f4aff661fa0b7764d791fb79', md5($result));
|
||||
}
|
||||
|
||||
public function testGetFormattedDate(): void
|
||||
{
|
||||
$permissions = ['print', 'modify', 'copy', 'annot-forms', 'fill-forms', 'extract', 'assemble', 'print-high'];
|
||||
|
||||
$enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(false);
|
||||
$result = $enc->getFormattedDate();
|
||||
$this->assertEquals('(D:', substr($result, 0, 3));
|
||||
$this->assertEquals("+00'00')", substr($result, -8));
|
||||
|
||||
$enc = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 0, $permissions, 'alpha');
|
||||
$result = $enc->getFormattedDate();
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
91
vendor/tecnickcom/tc-lib-pdf-encrypt/test/OutputTest.php
vendored
Normal file
91
vendor/tecnickcom/tc-lib-pdf-encrypt/test/OutputTest.php
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* OutputTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*
|
||||
* This file is part of tc-lib-pdf-encrypt software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* Output Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*/
|
||||
class OutputTest extends TestUtil
|
||||
{
|
||||
public function testGetPdfEncryptionObjZero(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 0, ['print'], 'alpha', 'beta');
|
||||
$pon = 122;
|
||||
$result = $encrypt->getPdfEncryptionObj($pon);
|
||||
$expected = '3132332030206f626a0a3c3c0a2f46696c746572202f5374616e646172640a2f5620310a2f4c656e6774682034300a2'
|
||||
. 'f5220320a2f4f20280542fa0e15496869a825cd08c633ac10675c5c02167661241f5369895d768278b1290a2f552028550539dc185'
|
||||
. 'e79d4c676f803babbdc50acf8a4427d2de5303d59e7c315b30eba290a2f5020323134373432323030380a2f456e63727970744d657'
|
||||
. '4616461746120747275650a3e3e0a656e646f626a0a';
|
||||
$this->assertEquals($expected, bin2hex($result));
|
||||
}
|
||||
|
||||
public function testGetPdfEncryptionObjOne(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 1, ['print'], 'alpha', 'beta');
|
||||
$pon = 122;
|
||||
$result = $encrypt->getPdfEncryptionObj($pon);
|
||||
$this->assertTrue(strlen($result) > 150);
|
||||
}
|
||||
|
||||
public function testGetPdfEncryptionObjTwo(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 2, ['print'], 'alpha', 'beta');
|
||||
$pon = 122;
|
||||
$result = $encrypt->getPdfEncryptionObj($pon);
|
||||
$this->assertTrue(strlen($result) > 200);
|
||||
}
|
||||
|
||||
public function testGetPdfEncryptionObjThree(): void
|
||||
{
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 3, ['print'], 'alpha', 'beta');
|
||||
$pon = 122;
|
||||
$result = $encrypt->getPdfEncryptionObj($pon);
|
||||
$this->assertTrue(strlen($result) > 300);
|
||||
}
|
||||
|
||||
public function testGetPdfEncryptionObjThreePub(): void
|
||||
{
|
||||
$pubkeys = [[
|
||||
'c' => __DIR__ . '/data/cert.pem',
|
||||
'p' => ['print'],
|
||||
]];
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 3, ['print'], 'alpha', 'beta', $pubkeys);
|
||||
$pon = 122;
|
||||
$result = $encrypt->getPdfEncryptionObj($pon);
|
||||
$this->assertTrue(strlen($result) > 200);
|
||||
}
|
||||
|
||||
public function testGetPdfEncryptionObjOnePub(): void
|
||||
{
|
||||
$pubkeys = [[
|
||||
'c' => __DIR__ . '/data/cert.pem',
|
||||
'p' => ['print'],
|
||||
]];
|
||||
$encrypt = new \Com\Tecnick\Pdf\Encrypt\Encrypt(true, md5('file_id'), 1, ['print'], 'alpha', 'beta', $pubkeys);
|
||||
$pon = 122;
|
||||
$result = $encrypt->getPdfEncryptionObj($pon);
|
||||
$this->assertTrue(strlen($result) > 100);
|
||||
}
|
||||
}
|
||||
41
vendor/tecnickcom/tc-lib-pdf-encrypt/test/TestUtil.php
vendored
Normal file
41
vendor/tecnickcom/tc-lib-pdf-encrypt/test/TestUtil.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* TestUtil.php
|
||||
*
|
||||
* @since 2020-12-19
|
||||
* @category Library
|
||||
* @package file
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-file
|
||||
*
|
||||
* This file is part of tc-lib-file software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* Test Util
|
||||
*
|
||||
* @since 2020-12-19
|
||||
* @category Library
|
||||
* @package file
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2015-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-file
|
||||
*/
|
||||
class TestUtil extends TestCase
|
||||
{
|
||||
/**
|
||||
* @param class-string<\Throwable> $exception
|
||||
*/
|
||||
public function bcExpectException($exception): void
|
||||
{
|
||||
parent::expectException($exception);
|
||||
}
|
||||
}
|
||||
73
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/AESTest.php
vendored
Normal file
73
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/AESTest.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* AESTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*
|
||||
* This file is part of tc-lib-pdf-encrypt software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* AES encryption Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*/
|
||||
class AESTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Pdf\Encrypt\Type\AES
|
||||
{
|
||||
return new \Com\Tecnick\Pdf\Encrypt\Type\AES();
|
||||
}
|
||||
|
||||
public function testEncrypt128(): void
|
||||
{
|
||||
$aes = $this->getTestObject();
|
||||
$data = 'alpha';
|
||||
$key = '0123456789abcdef'; // 16 bytes = 128 bit KEY
|
||||
|
||||
$enc_a = $aes->encrypt($data, $key);
|
||||
$enc_b = $aes->encrypt($data, $key, 'aes-128-cbc');
|
||||
$this->assertEquals(strlen($enc_a), strlen($enc_b));
|
||||
|
||||
$aesSixteen = new \Com\Tecnick\Pdf\Encrypt\Type\AESSixteen();
|
||||
$enc_c = $aesSixteen->encrypt($data, $key);
|
||||
$this->assertEquals(strlen($enc_a), strlen($enc_c));
|
||||
}
|
||||
|
||||
public function testEncrypt256(): void
|
||||
{
|
||||
$aes = $this->getTestObject();
|
||||
$data = 'alpha';
|
||||
$key = '0123456789abcdef0123456789abcdef'; // 32 bytes = 256 bit KEY
|
||||
|
||||
$enc_a = $aes->encrypt($data, $key, '');
|
||||
$enc_b = $aes->encrypt($data, $key, 'aes-256-cbc');
|
||||
$this->assertEquals(strlen($enc_a), strlen($enc_b));
|
||||
|
||||
$aesThirtytwo = new \Com\Tecnick\Pdf\Encrypt\Type\AESThirtytwo();
|
||||
$enc_c = $aesThirtytwo->encrypt($data, $key);
|
||||
$this->assertEquals(strlen($enc_a), strlen($enc_c));
|
||||
}
|
||||
|
||||
public function testEncryptException(): void
|
||||
{
|
||||
$this->bcExpectException('\\' . \Com\Tecnick\Pdf\Encrypt\Exception::class);
|
||||
$aes = $this->getTestObject();
|
||||
$aes->encrypt('alpha', '12345', 'ERROR');
|
||||
}
|
||||
}
|
||||
43
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/MDFiveSixteenTest.php
vendored
Normal file
43
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/MDFiveSixteenTest.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* MDFiveSixteenTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*
|
||||
* This file is part of tc-lib-pdf-encrypt software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* MD5-16 encryption Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*/
|
||||
class MDFiveSixteenTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Pdf\Encrypt\Type\MDFiveSixteen
|
||||
{
|
||||
return new \Com\Tecnick\Pdf\Encrypt\Type\MDFiveSixteen();
|
||||
}
|
||||
|
||||
public function testEncrypt(): void
|
||||
{
|
||||
$mdFiveSixteen = $this->getTestObject();
|
||||
$result = $mdFiveSixteen->encrypt('hello');
|
||||
$this->assertEquals('5d41402abc4b2a76b9719d911017c592', bin2hex($result));
|
||||
}
|
||||
}
|
||||
73
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/RCFourTest.php
vendored
Normal file
73
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/RCFourTest.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* RCFourTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*
|
||||
* This file is part of tc-lib-pdf-encrypt software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* RC4 encryption Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*/
|
||||
class RCFourTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Pdf\Encrypt\Type\RCFour
|
||||
{
|
||||
return new \Com\Tecnick\Pdf\Encrypt\Type\RCFour();
|
||||
}
|
||||
|
||||
public function testEncrypt40(): void
|
||||
{
|
||||
$rcFour = $this->getTestObject();
|
||||
$data = 'alpha';
|
||||
$key = '12345'; // 5 bytes = 40 bit KEY
|
||||
|
||||
$enc_a = $rcFour->encrypt($data, $key, '');
|
||||
$enc_b = $rcFour->encrypt($data, $key, 'RC4-40');
|
||||
$this->assertEquals($enc_a, $enc_b);
|
||||
|
||||
$rcFourFive = new \Com\Tecnick\Pdf\Encrypt\Type\RCFourFive();
|
||||
$enc_c = $rcFourFive->encrypt($data, $key);
|
||||
$this->assertEquals($enc_a, $enc_c);
|
||||
}
|
||||
|
||||
public function testEncrypt128(): void
|
||||
{
|
||||
$rcFour = $this->getTestObject();
|
||||
$data = 'alpha';
|
||||
$key = '0123456789abcdef'; // 16 bytes = 128 bit KEY
|
||||
|
||||
$enc_a = $rcFour->encrypt($data, $key);
|
||||
$enc_b = $rcFour->encrypt($data, $key, 'RC4');
|
||||
$this->assertEquals($enc_a, $enc_b);
|
||||
|
||||
$rcFourSixteen = new \Com\Tecnick\Pdf\Encrypt\Type\RCFourSixteen();
|
||||
$enc_c = $rcFourSixteen->encrypt($data, $key);
|
||||
$this->assertEquals($enc_a, $enc_c);
|
||||
}
|
||||
|
||||
public function testEncryptException(): void
|
||||
{
|
||||
$this->bcExpectException('\\' . \Com\Tecnick\Pdf\Encrypt\Exception::class);
|
||||
$rcFour = $this->getTestObject();
|
||||
$rcFour->encrypt('alpha', '12345', 'ERROR');
|
||||
}
|
||||
}
|
||||
50
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/SeedTest.php
vendored
Normal file
50
vendor/tecnickcom/tc-lib-pdf-encrypt/test/Type/SeedTest.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* SeedTest.php
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*
|
||||
* This file is part of tc-lib-pdf-encrypt software library.
|
||||
*/
|
||||
|
||||
namespace Test;
|
||||
|
||||
/**
|
||||
* Seed Test
|
||||
*
|
||||
* @since 2011-05-23
|
||||
* @category Library
|
||||
* @package PdfEncrypt
|
||||
* @author Nicola Asuni <info@tecnick.com>
|
||||
* @copyright 2011-2024 Nicola Asuni - Tecnick.com LTD
|
||||
* @license http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
|
||||
* @link https://github.com/tecnickcom/tc-lib-pdf-encrypt
|
||||
*/
|
||||
class SeedTest extends TestUtil
|
||||
{
|
||||
protected function getTestObject(): \Com\Tecnick\Pdf\Encrypt\Type\Seed
|
||||
{
|
||||
return new \Com\Tecnick\Pdf\Encrypt\Type\Seed();
|
||||
}
|
||||
|
||||
public function testEncrypt(): void
|
||||
{
|
||||
$seed = $this->getTestObject();
|
||||
$result = $seed->encrypt('hello', 'world');
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
|
||||
public function testEncryptRaw(): void
|
||||
{
|
||||
$seed = $this->getTestObject();
|
||||
$result = $seed->encrypt('hello', 'world', 'raw');
|
||||
$this->assertNotEmpty($result);
|
||||
}
|
||||
}
|
||||
33
vendor/tecnickcom/tc-lib-pdf-encrypt/test/data/cert.pem
vendored
Normal file
33
vendor/tecnickcom/tc-lib-pdf-encrypt/test/data/cert.pem
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
-----BEGIN PRIVATE KEY-----
|
||||
MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBALtxWB+0PKdvXMih
|
||||
p8+xkg4BzMH8MDyNQNqv56mhrQ5wM1icQaoB1dXWUZj8NRPgvzkhw7xJ98P3Kka7
|
||||
mLA2qDNGh77H8aYc64pIII8Xd1iQMbHVrUqtsEec7ZCHL3U63rLeERCqu+eibQl4
|
||||
2w14bdflcMun0xHN/aJyA7sJWmInAgMBAAECgYB8dGNomYl0OpLGe98qHeK1/ifv
|
||||
3PxCGB+plAYjMT/wSDsvaICI2rMaSjTfeQXc7urIikymJg6mROQDFufoiEHgtliz
|
||||
mQeQIss6xPoBeObRBptjPBnmREnB3pP1nBngDmDQj/BwDsxbHXiZxRvQNvvKllyE
|
||||
vF0i9ZjgT+Bh1/pKoQJBAOiEFZTZxMF+Ri3VVMEhV8CkMSom4815OPg+5RhS/mwX
|
||||
X5bBG6AdLbOYgvq1iMGnjRZs9Vquk+uzmpMw+Uds8rkCQQDOX9m2t2O51/QyROIY
|
||||
obJGHp4fyAtGHH/qbyFg3L7c/LolqqDnq+26tP7+UdKXMZeGMs1FeL4crLcpJab8
|
||||
rQvfAkA7zJScVrGCrg4whXgpv4CJG/FFDQFze+TJ+6sB6X5joFNGO132fOqfEO9G
|
||||
uV91prjjdpxXeSSz7tonVuYVl5CJAkBW8xNrZEDkIBSGyXbpIddWq7e7dDErzP4n
|
||||
68KIaPkRanmTPRyl/04eB/wXcqnjgcVxiR3rUz/mHO7eqzp74vzJAkB+O8VRe350
|
||||
4I9Ut/gZmUW3IiSVT2FfZezk2XoB3X+zFKfhdhNt0i8EUwoTTI1mwy3nUyqMc/sb
|
||||
JhEpQgcZ31SP
|
||||
-----END PRIVATE KEY-----
|
||||
-----BEGIN CERTIFICATE-----
|
||||
MIICsDCCAhmgAwIBAgIUAQb8DRdrYNBU56/iGjwLAKJ3dLQwDQYJKoZIhvcNAQEL
|
||||
BQAwajELMAkGA1UEBhMCVUsxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM
|
||||
GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEjMCEGCSqGSIb3DQEJARYUdGVzdEBl
|
||||
eGFtcGxlLmludmFsaWQwHhcNMjIxMjIxMTExNjA5WhcNMzIxMjE4MTExNjA5WjBq
|
||||
MQswCQYDVQQGEwJVSzETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
|
||||
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMSMwIQYJKoZIhvcNAQkBFhR0ZXN0QGV4YW1w
|
||||
bGUuaW52YWxpZDCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAu3FYH7Q8p29c
|
||||
yKGnz7GSDgHMwfwwPI1A2q/nqaGtDnAzWJxBqgHV1dZRmPw1E+C/OSHDvEn3w/cq
|
||||
RruYsDaoM0aHvsfxphzrikggjxd3WJAxsdWtSq2wR5ztkIcvdTrest4REKq756Jt
|
||||
CXjbDXht1+Vwy6fTEc39onIDuwlaYicCAwEAAaNTMFEwHQYDVR0OBBYEFLULVT3y
|
||||
ounwqaWxwEaFOs7s0+DFMB8GA1UdIwQYMBaAFLULVT3younwqaWxwEaFOs7s0+DF
|
||||
MA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQELBQADgYEAJ8Gh0uOLLZA3UsmL
|
||||
eUxOrS19QbfNuDzfayiOuLwiMCKCY29ch/HEaKPdvUuGAbFczhnryJLsb6TYBBeP
|
||||
a4zUcyhylafqZH450awKEOxd/5ns0QoWlFeBkgVSHK/j7BP8P9LXZkjM4nLJXoAl
|
||||
M/SOSeyHUEHfE97284X8VaNPCT4=
|
||||
-----END CERTIFICATE-----
|
||||
Reference in New Issue
Block a user