I am writing a program that writes an assigned string to an encryptor (and finally understand).
The function has two arguments: string and seed value.
Even I have so far:
def random_encipher (string, seed): random.seed (seed) alphabet = ["A", " B "," C "," D "," E "," F "," G "," H "," I "," J "," K "," L "," Me "," N " , "P", "X", "Y", "Z"], "O", "P", "X", "X", "R", "S", "T", "U", "V", "W", Shuffle alphabet random For each letter in the alphabet alphabet in the Shuffle (alphabet) alphabet, type: letter = ord (letter) -97
To basically I am altering the alphabet and each letter ("A" = 0, "b" = 1, ...)
Here I need help with:
Let me < Strong> string [0] needs to be printed in the form of alphabet [0] (which is the alphabetical shuffle, hence the current Seed value, [0] = "E" with alphabet)
But for each letter of the string, not just the zero index.
Maybe something like that?
gt; & Gt; Import Random & gt; & Gt; & Gt; Def Random_exefeir (string, bead): random Seed (seed) Alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "J", "Kashmir", " "V", "w", "x", "v", "w", "x", "y", "n", "o", "p", "q", "r", "s" , "Y", "z"] # shuffle alphabet random. Shuffle (alphabet) cipher = [] For each letter in the alphabet, for each letter in the alphabet: index = ord (letter) -97 cipher = alphabet [index] cipher .Appendix (cipher) Returns "" .join (cipher) >> gt; & gt; Using a list means that the string becomes irreversible It is necessary to make a copy of the string adding to the string, which is expensive. Joining a list and finally merging elements is a better option (or use one).
No comments:
Post a Comment