/gdata/tlslite/utils/PyCrypto_RC4.py

http://radioappz.googlecode.com/ · Python · 22 lines · 14 code · 7 blank · 1 comment · 1 complexity · 641db39cf5c819cc32440dde5ed829b9 MD5 · raw file

  1. """PyCrypto RC4 implementation."""
  2. from cryptomath import *
  3. from RC4 import *
  4. if pycryptoLoaded:
  5. import Crypto.Cipher.ARC4
  6. def new(key):
  7. return PyCrypto_RC4(key)
  8. class PyCrypto_RC4(RC4):
  9. def __init__(self, key):
  10. RC4.__init__(self, key, "pycrypto")
  11. self.context = Crypto.Cipher.ARC4.new(key)
  12. def encrypt(self, plaintext):
  13. return self.context.encrypt(plaintext)
  14. def decrypt(self, ciphertext):
  15. return self.context.decrypt(ciphertext)