MCPcopy Create free account
hub / github.com/ActiveState/code / decode_file

Function decode_file

recipes/Python/572159_SPICE/recipe-572159.py:92–107  ·  view source on GitHub ↗

Decrypt a file from source to destination.

(source, destination, major, minor)

Source from the content-addressed store, hash-verified

90 string = source.read(2 ** 20 / 5)
91
92def decode_file(source, destination, major, minor):
93 'Decrypt a file from source to destination.'
94 _check_major(major)
95 _check_minor(minor)
96 map_1 = _decode_map_1(minor)
97 map_2 = _decode_map_2(major)
98 string = source.read(2 ** 20 / 5 * 4)
99 while string:
100 tail_len = len(string) % 4
101 if tail_len == 0:
102 destination.write(_decode(string, map_1, map_2))
103 string = source.read(2 ** 20 / 5 * 4)
104 else:
105 destination.write(_decode(string[:-tail_len], map_1, map_2))
106 return string[-tail_len:]
107 return ''
108
109################################################################################
110

Callers

nothing calls this directly

Calls 7

_decode_map_1Function · 0.85
_decode_map_2Function · 0.85
_check_majorFunction · 0.70
_check_minorFunction · 0.70
_decodeFunction · 0.70
readMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected