From 82f214578f55b87744f4365a398de4cce0a00071 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 18 Mar 2022 23:08:14 +0800 Subject: [PATCH] bugfix --- appPublic/rc4.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/appPublic/rc4.py b/appPublic/rc4.py index 6412e5e..d6a0fde 100644 --- a/appPublic/rc4.py +++ b/appPublic/rc4.py @@ -64,6 +64,8 @@ class RC4: class KeyChain(object): def __init__(self, seed_str, crypter=None, keylen=23, period=600, threshold=60, time_delta=0): self.seed_str = seed_str + if isinstance(self.seed_str, str): + self.seed_str = self.seed_str.encode('utf-8') self.period = int(period) self.threshold = int(threshold) self.crypter = crypter @@ -114,7 +116,7 @@ class KeyChain(object): while k1 < self.keylen: j = v % self.keylen v = v - (j + k1) * m + self.keylen - k = k + self.seed_str[j] + k = k + chr(self.seed_str[j]) k1 += self.threshold / 2 key = k.encode('utf-8') self.keypool[vv] = key