MCPcopy
hub / github.com/shadowsocks/shadowsocks / get_cipher

Method get_cipher

shadowsocks/encrypt.py:97–110  ·  view source on GitHub ↗
(self, password, method, op, iv)

Source from the content-addressed store, hash-verified

95 return len(self.cipher_iv)
96
97 def get_cipher(self, password, method, op, iv):
98 password = common.to_bytes(password)
99 m = self._method_info
100 if m[0] > 0:
101 key, iv_ = EVP_BytesToKey(password, m[0], m[1])
102 else:
103 # key_length == 0 indicates we should use the key directly
104 key, iv = password, b''
105 self.key = key
106 iv = iv[:m[1]]
107 if op == 1:
108 # this iv is for cipher not decipher
109 self.cipher_iv = iv[:m[1]]
110 return m[2](method, key, iv, op)
111
112 def encrypt(self, buf):
113 if len(buf) == 0:

Callers 2

__init__Method · 0.95
decryptMethod · 0.95

Calls 1

EVP_BytesToKeyFunction · 0.85

Tested by

no test coverage detected