Exemple #1
0
def dump_header(header: Header, stream: typing.BinaryIO, mac: bytes = None):
    stream.write(AGE_INTRO.encode("utf-8") + b"\n")

    for recipient in header.recipients:
        line = RECIPIENT_PREFIX + " " + recipient.type + " " + " ".join(recipient.arguments) + "\n"
        stream.write(line.encode("utf-8"))
        if recipient.body:
            wrapped = textwrap.fill(recipient.body, break_on_hyphens=False, width=64)
            stream.write(wrapped.encode("utf-8") + b"\n")

    footer = FOOTER_PREFIX
    if mac:
        footer += " " + encode(mac)

    stream.write(footer.encode("utf-8"))
Exemple #2
0
 def dump(self) -> typing.Tuple[typing.List[str], str]:
     return [encode(self.salt), str(self.log_cost)], encode(self.encrypted_file_key)
Exemple #3
0
 def dump(self) -> typing.Tuple[typing.List[str], str]:
     return [encode(self.fingerprint)], encode(self.encrypted_file_key)
Exemple #4
0
 def dump(self) -> typing.Tuple[typing.List[str], str]:
     return [encode(self.derived_secret)], encode(self.encrypted_file_key)