bugfix
This commit is contained in:
parent
81878c7642
commit
6b6fe73f1c
@ -38,10 +38,11 @@ class RC4:
|
|||||||
if type(data)==type(''):
|
if type(data)==type(''):
|
||||||
data = data.encode(self.dcoding)
|
data = data.encode(self.dcoding)
|
||||||
key = key.encode(self.bcoding)
|
key = key.encode(self.bcoding)
|
||||||
self.encode_bytes(data, key)
|
code = self.encode_bytes(data, key)
|
||||||
if encode:
|
if encode:
|
||||||
data = encode(data)
|
code = encode(code)
|
||||||
return data.decode(self.dcoding)
|
return code.decode(self.dcoding)
|
||||||
|
return code
|
||||||
|
|
||||||
def decode_bytes(self, data, key):
|
def decode_bytes(self, data, key):
|
||||||
salt_length = 16
|
salt_length = 16
|
||||||
@ -165,6 +166,35 @@ class KeyChain(object):
|
|||||||
if d is None:
|
if d is None:
|
||||||
return None
|
return None
|
||||||
return d.decode('utf-8')
|
return d.decode('utf-8')
|
||||||
|
pwdkey = 'ytguiojbhvhbnkl'
|
||||||
|
def password(pwdtxt):
|
||||||
|
rc = RC4()
|
||||||
|
code = rc.encode(pwdtxt, pwdkey)
|
||||||
|
t = rc.decode(code, pwdkey)
|
||||||
|
if (t == pwdtxt):
|
||||||
|
return code
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
def unpassword(code):
|
||||||
|
rc = RC4()
|
||||||
|
t = rc.decode(code, pwdkey)
|
||||||
|
return t
|
||||||
|
|
||||||
|
"""
|
||||||
|
if __name__ == '__main__':
|
||||||
|
import sys
|
||||||
|
if len(sys.argv) > 1:
|
||||||
|
print(password(sys.argv[1]))
|
||||||
|
sys.exit(0)
|
||||||
|
ps = [
|
||||||
|
'45dr6tcfyvguh',
|
||||||
|
'ft7gy8uh9ij0',
|
||||||
|
'opiluykhcgjfncm'
|
||||||
|
]
|
||||||
|
for p in ps:
|
||||||
|
print(password(p))
|
||||||
|
"""
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
# 需要加密的数据长度没有限制
|
# 需要加密的数据长度没有限制
|
||||||
|
Loading…
Reference in New Issue
Block a user