encryption - Fast RC4 cipher stream for Python? -


i'm trying write app needs large numbers of cryptographic strength pseudorandom bytes.

the rc4 cipher ideal this; it's lightweight , simple understand conceptually. so, got spec , wrote rc4 algorithm in python.

it works expected, but, it's slow molasses. on core i7 2.2ghz, can 1mb/sec out of algorithm.

clearly interpreted nature of python not best suited sort of task. problem i'm not versed in c coding - best i've done c hello world stuff , experiments file reading , writing. either way, not enough c use python-c apis.

i know .net/c#, , wrote same algorithm in windows on c#, , able on 60mb/sec out of it. .net's clr lot more optimized. but, target platform python app unix/linux.

ideally, don't want have go through tons of middle-layers optimized rc4 cipher python app.

since rc4 depends on state, ideally i'd class (that's how did python-only implementation.) so, here's small snippet of want able do:

rc4 = rc4encrypter() rc4.seed(mykey) # seed rc4 algorithm bytes string mykey rc4.getrc4bytes(1048576) # next 1mb of rc4 cryptostream bytes binary string rc4.encryptwithrc4(mystring) # encrypt mystring's bytes rc4 bytes using xor , return 

any advice? i'd love learn c it's big learning curve right simple project.

i believe pycrypto has rc4 implementation, check out here


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -