<file_sep>base_64_symbol = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"

def asc2bin(plain_text):
    ascii_list = []
    total_bin = ""
    binary_txt = ""
    for i in range(len(plain_text)):
        ascii_list.append(ord(plain_text[i]))
    for i in ascii_list:
        while True:
            div = i // 2
            mod = i % 2
            i = div
            binary_txt += str(mod)
            if div == 0:
                break
        total_bin += ("0" + binary_txt[::-1])
        binary_txt = ""
    return total_bin

def base64_encrypt(plain_text):
    l1 = []
    total = ""
    return_value = asc2bin(plain_text)
    while len(return_value) % 6 != 0:
        return_value += "0"
    index_bin = [return_value[i:i+6] for i in range(0, len(return_value), 6)]
    for i in index_bin:
        dec = 0
        pow_num = 0
        i = list(str(i))
        i = i[::-1]
        for bin_num in i:
            if bin_num == "1":
                dec += 2**pow_num
            pow_num += 1
        l1.append(dec)
    for num in l1:
        total += base_64_symbol[num]
    if len(total) % 4 == 2:
        total += "=="
    elif len(total) % 4 == 3:
        total += "="

    return total<file_sep>####### Declaration #######
eng_alphabet_small = "abcdefghijklmnopqrstuvwxyz"
eng_alphabet_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
plain_text = ""

####### Definition #######
def caesar_decrypt(cipher_text, key):
    global plain_text
    for index_num in range(len(cipher_text)):
        index_str = cipher_text[index_num]
        if index_str.islower() == True:
            position_num = eng_alphabet_small.index(index_str)
            replace_position_num = (position_num - key) % 26
            plain_text += eng_alphabet_small[replace_position_num]
        elif index_str.isupper() == True:
            position_num = eng_alphabet_big.index(index_str)
            replace_position_num = (position_num - key) % 26
            plain_text += eng_alphabet_big[replace_position_num]
        elif index_str.isalpha() == False:
            plain_text += index_str
            
    return plain_text<file_sep>####### Declaration #######
eng_alphabet_small = "abcdefghijklmnopqrstuvwxyz"
eng_alphabet_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
cipher_text = ""

####### Definition #######
def caesar_encrypt(plain_text, shift_num):
    global cipher_text
    for index_num in range(len(plain_text)):
        index_str = plain_text[index_num]
        if index_str.islower() == True:
            position_num = eng_alphabet_small.index(index_str)
            replace_position_num = (position_num + shift_num) % 26
            cipher_text += eng_alphabet_small[replace_position_num]
        elif index_str.isupper() == True:
            position_num = eng_alphabet_big.index(index_str)
            replace_position_num = (position_num + shift_num) % 26
            cipher_text += eng_alphabet_big[replace_position_num]
        elif index_str.isalpha() == False:
            cipher_text += index_str
            
    return cipher_text<file_sep>####### Declaration #######
eng_alphabet_small = "abcdefghijklmnopqrstuvwxyz"
eng_alphabet_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
plain_text = ""
out_come_dic = {}

####### Definition #######
def caesar_decrypt(cipher_text):
    global plain_text
    for shift_num in range(26):
        for index_num in range(len(cipher_text)):
            index_str = cipher_text[index_num]
            if index_str.islower() == True:
                position_num = eng_alphabet_small.index(index_str)
                replace_position_num = (position_num - shift_num) % 26
                plain_text += eng_alphabet_small[replace_position_num]
            elif index_str.isupper() == True:
                position_num = eng_alphabet_big.index(index_str)
                replace_position_num = (position_num - shift_num) % 26
                plain_text += eng_alphabet_big[replace_position_num]
            elif index_str.isalpha() == False:
                plain_text += index_str
        out_come_dic[shift_num] = plain_text
        plain_text = ""
        
    return out_come_dic<file_sep>eng_alphabet_small = "abcdefghijklmnopqrstuvwxyz"
eng_alphabet_big = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
plain_text = ""
index_key_l1 = []
list_index = 0

def vignere_decrypt(cipher_text, key):
    global index_key_l1
    global plain_text
    global list_index
    for index_key_num in range(len(key)):
        index_key = key[index_key_num]
        if index_key.isupper() == True:
            index_key_num = eng_alphabet_big.index(index_key)
            index_key_l1.append(index_key_num)
        elif index_key.islower() == True:
            index_key_num = eng_alphabet_small.index(index_key)
            index_key_l1.append(index_key_num)
        elif index_key.isalpha() == False:
            index_key_l1.append(index_key)

    for index_num in range(len(cipher_text)):
        index_str = cipher_text[index_num]
        if list_index == len(key):
            list_index = 0
        if index_str.islower() == True:
            position_num = eng_alphabet_small.index(index_str)
            replace_position_num = (position_num - index_key_l1[list_index]) % 26
            plain_text += eng_alphabet_small[replace_position_num]
            list_index += 1
        elif index_str.isupper() == True:
            position_num = eng_alphabet_big.index(index_str)
            replace_position_num = (position_num - index_key_l1[list_index]) % 26
            plain_text += eng_alphabet_big[replace_position_num]
            list_index += 1
        elif index_str.isalpha() == False:
            plain_text += index_str
            
    return plain_text