コード例 #1
0
ファイル: decryption.py プロジェクト: james-langbein/PyCrypt
    def decrypt1(message, seed):
        """Decrypt a given message string with a given password string (seed)."""
        x = helpers.seed_generator(seed, 4)
        res = Decryptor.de_shuffle(message, x[3])
        res2 = Decryptor.de_shift(res, x[1], x[2])
        res3 = Decryptor.de_pad(res2, x[0])

        return res3
コード例 #2
0
ファイル: encryption.py プロジェクト: james-langbein/PyCrypt
    def encrypt4(message, seed, rounds=secrets.choice(range(5, 40))):
        """Encrypt with splitting, shifting and padding; plus multiple rounds of shuffling and shifting."""
        e = Encryptor()

        seeds = helpers.seed_generator(str(seed), n=2)

        x1 = helpers.seed_generator(seeds[0], n=3)
        res = e.group_split(message)
        res2 = e.char_shift(res, x1[0], x1[1])
        res3 = e.end_pad(res2, pad_size=1000, delim_seed=x1[2])

        x2 = helpers.seed_generator(seeds[1], n=rounds)[::-1]
        r_res = res3
        for i in range(rounds):
            r_seed = helpers.seed_generator(x2[i], n=3)
            r_res = e.char_shift(string=r_res, list_seed=r_seed[0], msg_seed=r_seed[1])
            r_res = e.char_shuffle(string=r_res, seed=r_seed[2])

        return r_res
コード例 #3
0
ファイル: decryption.py プロジェクト: james-langbein/PyCrypt
    def decrypt2(message, seed):
        """Decrypt a given message string with a given password string (seed)."""
        x = helpers.seed_generator(seed, n=6)
        res = Decryptor.de_shuffle(message, x[5])
        res2 = Decryptor.de_shift(res, x[3], x[4])
        res3 = Decryptor.de_pad(res2, x[2])
        res4 = Decryptor.de_shift(res3, x[0], x[1])
        res5 = Decryptor.de_split(res4)

        return res5
コード例 #4
0
ファイル: decryption.py プロジェクト: james-langbein/PyCrypt
    def decrypt3(message, seed, rounds=5):
        d = Decryptor()

        seeds = helpers.seed_generator(str(seed), n=2)
        x1 = helpers.seed_generator(seeds[0], n=3)
        x2 = helpers.seed_generator(seeds[1], n=rounds)

        x2_reversed = x2[::-1]
        r_res = message
        for i in range(rounds):
            r_seed = helpers.seed_generator(x2_reversed[i], n=3)
            r_res = d.de_shuffle(string=r_res, seed=r_seed[2])
            r_res = d.de_shift(string=r_res,
                               list_seed=r_seed[0],
                               msg_seed=r_seed[1])

        res = d.de_pad(r_res, delim_seed=x1[2])
        res2 = d.de_shift(res, x1[0], x1[1])
        res3 = d.de_split(res2)

        return res3
コード例 #5
0
ファイル: encryption.py プロジェクト: james-langbein/PyCrypt
    def encrypt1(message, seed):
        """Encrypt a given message string with a given password.
        Each encryption of the same message will be different, aside from the shuffled/shifted characters of the
        original string.
        So, if the original string had 20 chars, then the encrypted result chars from that string will all be present in
        each full encryption result.
        This would present an opening to cryptographers if the same message was sent too many times with their
        knowledge. But only to the encrypted characters."""
        x = helpers.seed_generator(str(seed), n=4)
        res = Encryptor.end_pad(message, pad_size=1000, delim_seed=x[0])
        res2 = Encryptor.char_shift(string=res, list_seed=x[1], msg_seed=x[2])
        res3 = Encryptor.char_shuffle(string=res2, seed=x[3])

        return res3
コード例 #6
0
ファイル: decryption.py プロジェクト: james-langbein/PyCrypt
    def decrypt4(message, seed, max_rounds=42):
        d = Decryptor()

        seeds = helpers.seed_generator(str(seed), n=2)
        x1 = helpers.seed_generator(seeds[0], n=3)
        x2 = helpers.seed_generator(seeds[1], n=max_rounds)

        delimiter = helpers.delimiter(x1[2])
        r_res = message
        for i in range(max_rounds):
            r_seed = helpers.seed_generator(x2[i], n=3)
            r_res = d.de_shuffle(string=r_res, seed=r_seed[2])
            r_res = d.de_shift(string=r_res,
                               list_seed=r_seed[0],
                               msg_seed=r_seed[1])
            if delimiter in r_res:
                break

        res = d.de_pad(r_res, delim_seed=x1[2])
        res2 = d.de_shift(res, x1[0], x1[1])
        res3 = d.de_split(res2)

        return res3