Helppo ja nopea (ja heikko) salakirjoitusalgoritmi niille, jotka eivät tarvitse Pythonin omia, kunnollisia salakirjoitusalgoritmeja
def crypt(string, password):
""" Either crypt or decrypt the string. Pass encrypted string with
same password to decrypt.
Example:
>>> s = "Monty Python's flying circus"
>>> s = crypt(s, "SPAM")
>>> s
"�?/9*p�4'8.#t#a+?)(#4p"$!34>"
>>> s = crypt(s, "SPAM")
>>> s
"Monty Python's flying circus"
"""
# crypt("Monty Python", "SPAM") <=> "Monty Python" ^ "SPAMSPAMSPAM"
return [chr(ord(char) ^ ord(password[index % length])) \
for (index, char) in enumerate(string)]Aihe on jo aika vanha, joten et voi enää vastata siihen.