mirror of
https://github.com/progval/Limnoria.git
synced 2025-04-27 05:21:09 -05:00
Changed implementation of xor command to be cooler.
This commit is contained in:
parent
c5e48d574f
commit
c70007278c
@ -43,7 +43,7 @@ import sha
|
|||||||
import random
|
import random
|
||||||
import inspect
|
import inspect
|
||||||
import mimetypes
|
import mimetypes
|
||||||
from itertools import imap
|
from itertools import imap, cycle
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
@ -144,12 +144,10 @@ class Fun(callbacks.Privmsg):
|
|||||||
http://www.yoe.org/developer/xor.html for information about XOR
|
http://www.yoe.org/developer/xor.html for information about XOR
|
||||||
encryption.
|
encryption.
|
||||||
"""
|
"""
|
||||||
passwordlen = len(password)
|
chars = cycle(password)
|
||||||
i = 0
|
|
||||||
ret = []
|
ret = []
|
||||||
for c in text:
|
for c in text:
|
||||||
ret.append(chr(ord(c) ^ ord(password[i])))
|
ret.append(chr(ord(c) ^ ord(chars.next())))
|
||||||
i = (i + 1) % passwordlen
|
|
||||||
irc.reply(''.join(ret))
|
irc.reply(''.join(ret))
|
||||||
xor = wrap(xor, ['something', 'text'])
|
xor = wrap(xor, ['something', 'text'])
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user