I am writing a program that enciphers (and will eventually decipher) a given string.
The encipher function takes two arguments: the string and a seed value.
Here is what I have so far:
def random_encipher(string,seed):
seed = random.seed(seed)
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#shuffle alphabet
random.shuffle(alphabet)
#assign index to each letter in alphabet
for letter in alphabet:
letter = ord(letter)-97
To sum all that up, basically I'm shuffling the alphabet and assigning each letter a number value ("a" = 0, "b" = 1, . . .)
Here's what I need help with:
I need string[0] to be printed as alphabet[0] (which is the shuffled alphabet, therefore with the current seed value, alphabet[0] = "e").
But for each letter of the string, not just the zero index.
Any help would be greatly appreciated.
Aucun commentaire:
Enregistrer un commentaire