def do_simple_substitution(ciphertext, pt_charset, ct_charset):
'''
Perform simple substitution based on character sets
Simplifies the use of string.translate(). If, for instance, you wish to
transform a ciphertext where 'e' is swapped with 't', you would call this
function like so:
do_simple_substitution('Simplt subeieueion ciphtrs art silly','et','te')
ciphertext - A string to translate
pt_charset - The character set of the plaintext, usually 'abcdefghijk...xyz'
ct_charset - The character set of the ciphertext
'''
#translate ciphertext to plaintext using mapping
return string.translate(ciphertext, string.maketrans(ct_charset, pt_charset))
# TODO: Implement chi square
评论列表
文章目录