lib/crypto: implement samba.crypto Python module for RC4
[samba.git] / python / samba / __init__.py
index 3535704ea0c8fe6945f904e9f8389c8412ff89d4..67aa82300f93017f8efe3474d659040e9976ff0f 100644 (file)
@@ -375,20 +375,8 @@ def string_to_byte_array(string):
     return blob
 
 def arcfour_encrypt(key, data):
-    try:
-        from Crypto.Cipher import ARC4
-        c = ARC4.new(key)
-        return c.encrypt(data)
-    except ImportError as e:
-        pass
-    try:
-        from M2Crypto.RC4 import RC4
-        c = RC4(key)
-        return c.update(data)
-    except ImportError as e:
-        pass
-    raise Exception("arcfour_encrypt() requires " +
-                    "python*-crypto or python*-m2crypto or m2crypto")
+    from samba.crypto import arcfour_crypt_blob
+    return arcfour_crypt_blob(data, key)
 
 version = _glue.version
 interface_ips = _glue.interface_ips