This Python function encrypt/decrypt a string with the Porta cipher:
def Porta(plain, key):
alpha26 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # standard alphabet
numkey = [alpha26.index(c)//2 for c in key]
crypto = ''
keyidx = 0
for c in plain:
idx = alpha26.index(c)
if idx < 13: # c in the first half of alpha26
crypto += alpha26[(idx + numkey[keyidx])%13 + 13]
else: # c in the second half of alpha26
crypto += alpha26[(idx - numkey[keyidx])%13]
keyidx = (keyidx+1)%len(key) # increment key index
return crypto
Encryption
Porta('PORTACIPHERWITHOUTATABLE', 'SECRET')
Decryption
Porta('GMDLPYRAVZCAREVGFKWEOWNN', 'SECRET')
Le 27/12/2021 - Contact : Rossignol@bribes.org