github
3964 of 5790 branches covered (68.46%)
Branch coverage included in aggregate %.
66 of 95 new or added lines in 4 files covered. (69.47%)
958 existing lines in 43 files now uncovered.11139 of 13847 relevant lines covered (80.44%)
0.8 hits per line
1 |
# Author: Trevor Perrin
|
|
2 |
# See the LICENSE file for legal information regarding use of this file.
|
|
3 |
|
|
UNCOV
4
|
"""PyCrypto RC4 implementation."""
|
× |
5 |
|
|
UNCOV
6
|
from .cryptomath import * |
× |
UNCOV
7
|
from .rc4 import * |
× |
8 |
|
|
UNCOV
9
|
if pycryptoLoaded:
|
|
UNCOV
10
|
import Crypto.Cipher.ARC4 |
× |
11 |
|
|
UNCOV
12
|
def new(key): |
× |
UNCOV
13
|
return PyCrypto_RC4(key)
|
× |
14 |
|
|
UNCOV
15
|
class PyCrypto_RC4(RC4): |
× |
16 |
|
|
UNCOV
17
|
def __init__(self, key): |
× |
UNCOV
18
|
RC4.__init__(self, key, "pycrypto") |
× |
UNCOV
19
|
key = bytes(key)
|
× |
UNCOV
20
|
self.context = Crypto.Cipher.ARC4.new(key)
|
× |
21 |
|
|
UNCOV
22
|
def encrypt(self, plaintext): |
× |
UNCOV
23
|
plaintext = bytes(plaintext)
|
× |
UNCOV
24
|
return bytearray(self.context.encrypt(plaintext)) |
× |
25 |
|
|
UNCOV
26
|
def decrypt(self, ciphertext): |
× |
UNCOV
27
|
ciphertext = bytes(ciphertext)
|
× |
UNCOV
28
|
return bytearray(self.context.decrypt(ciphertext)) |
× |