@
clowwindy 但是使用相同的key和plaintext,得到的密文在不同的环境都是不同的结果。。。就想到纠结了
结果如下
# cat
test.pyimport encrypt
print repr(encrypt.encrypt("\x05\x01\x00", key="123456"))
# python
test.py'\xf6\x1df'
# ipython
In [1]: import test
'0a/'
In [2]: import encrypt
In [3]: print repr(encrypt.encrypt("\x05\x01\x00", key="123456"))
'0a/'
encrypt的代码:
def encrypt(buf, key, iv="123456"):
cipher = Cipher(alg='rc4', key= key, iv=iv, op=1, d='md5', key_as_bytes=0)
cipher.set_padding(padding=0)
v = cipher.update(buf)
v = v+cipher.final()
out = ""
for i in v:
out += "%02x" % (ord(i))
#if __DEBUG__:
# print out
return v