From c70007278c1546149bdbe371efddc3cba2b9f920 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Fri, 10 Dec 2004 07:04:10 +0000 Subject: [PATCH] Changed implementation of xor command to be cooler. --- plugins/Fun.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/plugins/Fun.py b/plugins/Fun.py index b71140917..da3727907 100644 --- a/plugins/Fun.py +++ b/plugins/Fun.py @@ -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'])