<commit_before># -*- coding: utf-8 -*-
"""
Vigenère cipher encryption/decryption toolkit
Author: <NAME>

Allows working with non-Latin alphabets
"""

class CryptoAlphabet(object):
    """
    A class that represents a particular alphabet.
    
    TODO: Add more detailed documentation
    """
    _alphabet = ""
    _alphaSize = 0
    _letter_index = {}
    _letter_frequencies = {} # TODO: Implement this
    
    def __init__(self, alphabetString):
        """
        TODO: Add documentation
        """
        self._alphabet = alphabetString.lower()
        self._alphaSize = len(self._alphabet)
        for i in range(len(self._alphabet)):
            self._letter_index[self._alphabet[i]] = i
        
    def encrypt(self, plaintext, key, decrypt=False):
        """
        TODO: Add documentation
        """
        result = []
        key = key.lower()
        key = [char for char in key] #Convert key from string to list of characters
        for i in range(len(key)):
        # Remove characters from the key if they are not in the alphabet
        # that we are using:
            if key[i] not in self._letter_index:
                key.pop(i) #This is O(len(key)), rather than constant time
                # TODO: Maybe replace this with something that is constant time?
        keyIndex = 0
        
        for char in plaintext:
            if char.lower() not in self._letter_index:
                #Put it straight into result without encrypting it
                result.append(char)
            else:
                is_capital = char.isupper()
                char = char.lower()
                letterVal = self._letter_index[char]
                keyVal = self._letter_index[key[keyIndex]]
                if decrypt: #To decrypt, we subtract keyVal instead of adding it
                    keyVal *= -1
                newChar = self._alphabet[(letterVal + keyVal) % self._alphaSize]<commit_msg>Added files via upload<commit_after># -*- coding: utf-8 -*-
"""
Vigenère cipher encryption/decryption toolkit
Author: <NAME>

Allows working with non-Latin alphabets
"""

class CryptoAlphabet(object):
    """
    A class that represents a particular alphabet.
    
    TODO: Add more detailed documentation
    """
    _alphabet = ""
    _alphaSize = 0
    _letter_index = {}
    _letter_frequencies = {} # TODO: Implement this
    
    def __init__(self, alphabetString):
        """
        TODO: Add documentation
        """
        self._alphabet = alphabetString.lower()
        self._alphaSize = len(self._alphabet)
        for i in range(len(self._alphabet)):
            self._letter_index[self._alphabet[i]] = i
        
    def encrypt(self, plaintext, key, decrypt=False):
        """
        TODO: Add documentation
        """
        result = []
        key = key.lower()
        keyList = []
        #Convert key from string to list of characters:
        for character in key:
            if character in self._letter_index:
                # Only valid characters should be in key
                keyList.append(character)
        keyIndex = 0
        
        for char in plaintext:
            if char.lower() not in self._letter_index:
                #Put it straight into result without encrypting it
                result.append(char)
            else:
                is_capital = char.isupper()
                char = char.lower()
                letterVal = self._letter_index[char]
                keyVal = self._letter_index[keyList[keyIndex]]
                if decrypt: #To decrypt, we subtract keyVal instead of adding it
                    keyVal *= -1
                newChar = self._alphabet[(letterVal + keyVal) % self._alphaSize]
{'fraction_non_alphanumeric': 0.08987547374120194, 'fraction_numerical': 0.002165674066053059, 'mean_word_length': 1.8621223857474827, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4755372', 'n_tokens_mistral': 1009, 'n_tokens_neox': 969, 'n_words': 302}