An implementation of Bacon's cipher

This is a naive implementation of Bacon's cipher algorithm invented by Francis Bacon. for details of the algorithm see Wikipedia.

No special library needed. Just need to have python 3+.

USAGE:

secret_message = 'sourena';
cover_message = "Bacon's cipher or the Baconian cipher is a method of steganography"
print(bacon_cipher(secret_message,cover_message);
#OUTPUT RESULT
BacOn's CIPhEr Or tHe baConIan cIPhEr is a method of steganography.
DECODE PROCESS:
print(bacon_decipher("BacOn's CIPhEr Or tHe baConIan cIPhEr is a method of steganography");
#OUTPUT RESULT
sourena

 

bacon_table = {
    'A':'aaaaa','B':'aaaab','C':'aaaba','D':'aaabb',
    'E':'aabaa','F':'aabab','G':'aabba','H':'aabbb',
    'I':'abaaa','J':'abaab','K':'ababa','L':'ababb',
    'M':'abbaa','N':'abbab','P':'abbbb','Q':'baaaa', 
    'R':'baaab','S':'baaba','U':'babaa','T':'baabb',
    'V':'babab','W':'babba','X':'babbb','Y':'bbaaa',
    'Z':'bbaab','O':'abbba'
}

def bacon_cipher(secret_msg,cover):
    #count the alphabetical lenght of the cover message
    count = 0;
    secret_msg = secret_msg.upper();
    cover = cover.lower();
    for x in cover:
        if x>='a' and x<='z':
            count += 1;
        #end if
    #end for
    if (count<(len(secret_msg)*5)):
        print("cover message length must be 5 times of secret message length");
        return;
    #end if
    temp = '';
    cover = list(cover);
    for x in secret_msg:
        if x <'A' or x>'Z':
            print("Error: secret msg should be alphabetical");
            return;
        #end if
    #end for
    temp = [bacon_table[x] for x in secret_msg];
    temp = ''.join(temp);
    letter = '';
    msg_index = 0;
    for i in range(len(cover)):
        if cover[i]<'a' or cover[i]>'z':
            continue;
        #end if
        if msg_index == len(temp):
            break;
        else:
            letter = temp[msg_index];
            msg_index +=1;
        #end if
        if letter=='b':
            cover[i] = cover[i].upper();
        #end if
    #end for
    return ''.join(cover);

def bacon_decipher(cipher_msg):
    msg = '';
    dec = [];
    bacon_decode_table = {};
    for key in bacon_table:
        bacon_decode_table[bacon_table[key]] = key;
    for i in range(len(cipher_msg)):
        if(cipher_msg[i]>='a' and cipher_msg[i]<='z'):
           msg +='a';
        elif (cipher_msg[i]>='A' and cipher_msg[i]<='Z'):
            msg +='b';
        else:
            continue;
        #end if
    #end for
    for i in range(0,len(msg),5):
        if(i+5>len(msg)):
            break;
        #end if
        temp = msg[i:i+5];
        dec.append(bacon_decode_table[temp])
    return (''.join(dec)).lower();