<commit_before><?php

declare(strict_types=1);

namespace Dcrypt\Tests;

class AesBase extends \PHPUnit\Framework\TestCase
{
    public function testEngineInKeyMode()
    {
        $key = \Dcrypt\OpensslKey::create();

        $encrypted = static::$class::encrypt('a secret', $key);
        $decrypted = static::$class::decrypt($encrypted, $key);

        $this->assertEquals('a secret', $decrypted);
    }

    public function testEngineWithSomeRandomnessWhileInKeyMode()
    {
        $input = random_bytes(256);
        $key = \Dcrypt\OpensslKey::create();

        $encrypted = static::$class::encrypt($input, $key);
        $decrypted = static::$class::decrypt($encrypted, $key);

        $this->assertEquals($input, $decrypted);
    }

    public function testCorruptDataUsingKeyMode()
    {
        $key = \Dcrypt\OpensslKey::create();

        $encrypted = static::$class::encrypt('a secret', $key);

        $this->assertEquals('a secret', static::$class::decrypt($encrypted, $key));

        $this->expectException(\Dcrypt\Exceptions\InvalidChecksumException::class);

        static::$class::decrypt($encrypted . 'A', $key);
    }

    public function testInvalidKeyEncoding()
    {
        $this->expectException(\Dcrypt\Exceptions\InvalidKeyException::class);

        $crazyKey = str_repeat('?', 10000);

        static::$class::encrypt('a secret', $crazyKey);
    }

    public function testNameMatch()
    {
        // Make sure that the name has the cipher in it so that there can never be a mismatch between
        // the name of the cipher and the cipher given to openssl
        $testname1 = strtolower(str_replace('-', '', static::$class::CIPHER));
        $testname2 = strtolower(static::$class);

        $this->asserEquals($testname1, $testname2);
    }

    public function testKnownVector()
    {
        $json = json_decode(file_get_contents(__DIR__ . '/.vectors.json'));
        $c = $json->aes256->{static::$class};
        $d = static::$class::decrypt(base64_decode($c), $json->key);
        $this->assertEquals('a secret', $d);
    }
}
<commit_msg>( ͡~ ͜ʖ ͡°) fix broken function name<commit_after><?php

declare(strict_types=1);

namespace Dcrypt\Tests;

class AesBase extends \PHPUnit\Framework\TestCase
{
    public function testEngineInKeyMode()
    {
        $key = \Dcrypt\OpensslKey::create();

        $encrypted = static::$class::encrypt('a secret', $key);
        $decrypted = static::$class::decrypt($encrypted, $key);

        $this->assertEquals('a secret', $decrypted);
    }

    public function testEngineWithSomeRandomnessWhileInKeyMode()
    {
        $input = random_bytes(256);
        $key = \Dcrypt\OpensslKey::create();

        $encrypted = static::$class::encrypt($input, $key);
        $decrypted = static::$class::decrypt($encrypted, $key);

        $this->assertEquals($input, $decrypted);
    }

    public function testCorruptDataUsingKeyMode()
    {
        $key = \Dcrypt\OpensslKey::create();

        $encrypted = static::$class::encrypt('a secret', $key);

        $this->assertEquals('a secret', static::$class::decrypt($encrypted, $key));

        $this->expectException(\Dcrypt\Exceptions\InvalidChecksumException::class);

        static::$class::decrypt($encrypted . 'A', $key);
    }

    public function testInvalidKeyEncoding()
    {
        $this->expectException(\Dcrypt\Exceptions\InvalidKeyException::class);

        $crazyKey = str_repeat('?', 10000);

        static::$class::encrypt('a secret', $crazyKey);
    }

    public function testNameMatch()
    {
        // Make sure that the name has the cipher in it so that there can never be a mismatch between
        // the name of the cipher and the cipher given to openssl
        $testname1 = strtolower(str_replace('-', '', static::$class::CIPHER));
        $testname2 = strtolower(static::$class);

        $this->assertEquals($testname1, $testname2);
    }

    public function testKnownVector()
    {
        $json = json_decode(file_get_contents(__DIR__ . '/.vectors.json'));
        $c = $json->aes256->{static::$class};
        $d = static::$class::decrypt(base64_decode($c), $json->key);
        $this->assertEquals('a secret', $d);
    }
}

{'fraction_non_alphanumeric': 0.1579827915869981, 'fraction_numerical': 0.008604206500956023, 'mean_word_length': 3.2530487804878048, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1828689', 'n_tokens_mistral': 1315, 'n_tokens_neox': 1264, 'n_words': 245}