<commit_before>"""Test cases pbkdf2"""

import unittest
from wqflask.pbkdf2 import pbkdf2_hex


class TestPbkdf2(unittest.TestCase):
    def test_pbkdf2_hex(self):
        """
        Test pbkdf2_hex function
        """

        for password, salt, iterations, keylen, expected_value in [
                ('password', '<PASSWORD>', 1, 20,
                 '<PASSWORD>'),
                ('password', '<PASSWORD>', 2, 20,
                 '<PASSWORD>'),
                ('password', '<PASSWORD>', 4096, 20,
                 '<PASSWORD>'),
                ('passwordPASSWORDpassword',
                 '<PASSWORD>',
                 4096, 25,
                 '<PASSWORD>'),
                ('pass\x00word', '<PASSWORD>', 4096, 16,
                 '<PASSWORD>'),
                ('password', '<PASSWORD>', 1, 16,
                 '<PASSWORD>'),
                ('password', '<PASSWORD>', 1, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  '<PASSWORD>'
                  '3<PASSWORD>')),
                ('password', '<PASSWORD>', 2, 16,
                 '<PASSWORD>'),
                ('password', '<PASSWORD>', 2, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  '378b<PASSWORD>8a99'
                  'e61ad799d86')),
                ('password', '<PASSWORD>', 1200, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  '<PASSWORD>'
                  '42f708a31e2e62b1e13')),
                ('X' * 64, 'pass phrase equals block size', 1200, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  'ec59f1a452f5cc9ad'
                  '940fea0598ed1')),
                ('X' * 65, 'pass phrase exceeds block size', 1200, 32,
                 ('9ccad6d468770cd'
                  '51b10e6a68721be6'
                  '11a8b4d282601db3'
                  'b36be924691<PASSWORD>2a'))
        ]:
            self.assertEqual(
                pbkdf2_hex(data=password,
                           salt=salt,
                           iterations=iterations,
                           keylen=keylen),
                expected_value)<commit_msg>Pass salt as bytes when testing pbkdf2_hex<commit_after>"""Test cases pbkdf2"""

import unittest
from wqflask.pbkdf2 import pbkdf2_hex


class TestPbkdf2(unittest.TestCase):
    def test_pbkdf2_hex(self):
        """
        Test pbkdf2_hex function
        """

        for password, salt, iterations, keylen, expected_value in [
                ('password', b'salt', 1, 20,
                 '<PASSWORD>'),
                ('password', b'salt', 2, 20,
                 '<PASSWORD>'),
                ('password', b'<PASSWORD>', 4096, 20,
                 '<PASSWORD>'),
                ('passwordPASSWORDpassword',
                 b's<PASSWORD>SALTsaltSALTsaltSALTs<PASSWORD>SAL<PASSWORD>',
                 4096, 25,
                 '<PASSWORD>'),
                ('pass\<PASSWORD>', b'<PASSWORD>', 4096, 16,
                 '<PASSWORD>'),
                ('password', b'<PASSWORD>', 1, 16,
                 '<PASSWORD>'),
                ('password', b'<PASSWORD>', 1, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  '<PASSWORD>'
                  '<PASSWORD>')),
                ('password', b'<PASSWORD>', 2, 16,
                 '<PASSWORD>'),
                ('password', b'<PASSWORD>', 2, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  '<PASSWORD>'
                  'e6<PASSWORD>7<PASSWORD>86')),
                ('password', b'<PASSWORD>', 1200, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  '<PASSWORD>'
                  '42f<PASSWORD>a3<PASSWORD>6<PASSWORD>')),
                ('X' * 64, b'pass phrase equals block size', 1200, 32,
                 ('<PASSWORD>'
                  '<PASSWORD>'
                  'ec59f1a452f5cc9ad'
                  '940fea0598ed1')),
                ('X' * 65, b'pass phrase exceeds block size', 1200, 32,
                 ('9ccad6d468770cd'
                  '51b10e6a68721be6'
                  '11a8b4d282601db3'
                  'b36<PASSWORD>a'))
        ]:
            self.assertEqual(
                pbkdf2_hex(data=password,
                           salt=salt,
                           iterations=iterations,
                           keylen=keylen),
                expected_value)
{'fraction_non_alphanumeric': 0.1385379061371841, 'fraction_numerical': 0.06114620938628159, 'mean_word_length': 1.217608804402201, 'pattern_counts': {'":': 0, '<': 69, '<?xml version=': 0, '>': 69, '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': '7475252', 'n_tokens_mistral': 1464, 'n_tokens_neox': 1260, 'n_words': 233}