|
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17 System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64 User : nobody ( 99) PHP Version : 5.2.17 Disable Function : NONE Directory : /usr/lib64/python2.4/site-packages/M2Crypto/ |
Upload File : |
"""M2Crypto wrapper for OpenSSL RC4 API.
Copyright (c) 1999-2003 Ng Pheng Siong. All rights reserved."""
from m2 import rc4_new, rc4_free, rc4_set_key, rc4_update
class RC4:
"""Object interface to the stream cipher RC4."""
rc4_free = rc4_free
def __init__(self, key=None):
self.cipher = rc4_new()
if key:
rc4_set_key(self.cipher, key)
def __del__(self):
if getattr(self, 'cipher', None):
self.rc4_free(self.cipher)
def set_key(self, key):
rc4_set_key(self.cipher, key)
def update(self, data):
return rc4_update(self.cipher, data)
def final(self):
return ''