MCPcopy
hub / github.com/shadowsocks/shadowsocks / encrypt_all

Function encrypt_all

shadowsocks/encrypt.py:172–189  ·  view source on GitHub ↗
(password, method, op, data)

Source from the content-addressed store, hash-verified

170
171
172def encrypt_all(password, method, op, data):
173 result = []
174 method = method.lower()
175 (key_len, iv_len, m) = method_supported[method]
176 key = None
177 if key_len > 0:
178 key, _ = EVP_BytesToKey(password, key_len, iv_len)
179 else:
180 key = password
181 if op:
182 iv = random_string(iv_len)
183 result.append(iv)
184 else:
185 iv = data[:iv_len]
186 data = data[iv_len:]
187 cipher = m(method, key, iv, op)
188 result.append(cipher.update(data))
189 return b''.join(result)
190
191
192CIPHERS_TO_TEST = [

Callers 1

test_encrypt_allFunction · 0.85

Calls 3

EVP_BytesToKeyFunction · 0.85
random_stringFunction · 0.85
updateMethod · 0.45

Tested by 1

test_encrypt_allFunction · 0.68