"""
Data for competitions
:githublink:`%|py|5`
"""
from pyquickhelper.filehelper.encryption import encrypt_stream, decrypt_stream
[docs]def encrypt_data(password, input, output):
"""
Encrypts a file.
:param input: input filename
:param output: output filename
:param password: The encryption key - a string that must be either 16, 24 or 32
bytes long. Longer keys are more secure. If the data to encrypt
is in bytes, the key must be given in bytes too.
:githublink:`%|py|17`
"""
if not isinstance(password, bytes):
password = bytes(password, "ascii")
encrypt_stream(password, input, output)
[docs]def decrypt_data(password, input, output):
"""
Decrypts a file.
:param input: input filename
:param output: output filename
:param password: The encryption key - a string that must be either 16, 24 or 32
bytes long. Longer keys are more secure. If the data to encrypt
is in bytes, the key must be given in bytes too.
:githublink:`%|py|32`
"""
if not isinstance(password, bytes):
password = bytes(password, "ascii")
decrypt_stream(password, input, output)