欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python RC4加密

程序员文章站 2022-07-09 10:26:53
...
from Crypto.Cipher import ARC4
from binascii import b2a_hex, a2b_hex
def myRC4(data,key):
  rc41 = ARC4.new(key)
  encrypted = rc41.encrypt(data)
  return encrypted.encode('hex')

def rc4_decrpt_hex(data,key):
    rc41=ARC4.new(key)
    # print dir(rc41)
    return rc41.decrypt(a2b_hex(data))


key='Happy#12'
data=r'esbdata'
print myRC4(data,key)
print rc4_decrpt_hex('e79aaf7a42d9a1',key)