Hey Andy,
Problem:
I found a small bug when testing the code you provided:

I've located the problem to be with the lambda function you use to extract special characters, more specifically with:
extract_special_chars = lambda string: ([char for char in re.findall(r"[^\w]", string)], ...
Example input:
fpe_encrypt_or_decrypt('WD_DistServiceCapital', 'ENCRYPT')
Solution
Code throws an error when using underscores because it is part of \w character set.
I suggest changing it the following:
re.findall(r"[^a-zA-Z0-9]", string)
Hey Andy,
Problem:
I found a small bug when testing the code you provided:
I've located the problem to be with the lambda function you use to extract special characters, more specifically with:
Example input:
fpe_encrypt_or_decrypt('WD_DistServiceCapital', 'ENCRYPT')Solution
Code throws an error when using underscores because it is part of \w character set.
I suggest changing it the following:
re.findall(r"[^a-zA-Z0-9]", string)