Changed implementation of xor command to be cooler.

This commit is contained in:
Jeremy Fincher 2004-12-10 07:04:10 +00:00
parent c5e48d574f
commit c70007278c
1 changed files with 3 additions and 5 deletions

View File

@ -43,7 +43,7 @@ import sha
import random
import inspect
import mimetypes
from itertools import imap
from itertools import imap, cycle
import supybot.conf as conf
import supybot.utils as utils
@ -144,12 +144,10 @@ class Fun(callbacks.Privmsg):
http://www.yoe.org/developer/xor.html for information about XOR
encryption.
"""
passwordlen = len(password)
i = 0
chars = cycle(password)
ret = []
for c in text:
ret.append(chr(ord(c) ^ ord(password[i])))
i = (i + 1) % passwordlen
ret.append(chr(ord(c) ^ ord(chars.next())))
irc.reply(''.join(ret))
xor = wrap(xor, ['something', 'text'])