What iscveinnt
?
When I was 8, I was fascinated with cryptopgraphy and loved playing with ciphers.
cveinnt
is the result of passingvincent
to theEnigma machine under a simple setting, illustrated here:
As shown, each character is shifted by its one-based index in the word, i.e.:
defencrypt(text="vincent"):# encryption only works when len is odd, can you think of why? l= len(text)if len(text)%2==1else len(text)+1# shifted index is (1th_index + 1th_index) % 7# for example, v's shifted index is (1 + 1) % 7 = 2 shifted_index= [2* (i+1)% lfor iin range(len(text))]# return a new string based on shifted indexreturn"".join([text[shifted_index.index((i+1)% l)]for iin range(len(text))])encrypt()# returns 'cveinnt'