27 lines
748 B
Python
27 lines
748 B
Python
|
|
def construct_vcard(email: str, public_key: str) -> str:
|
|
"""Construct a VCard 4.0 string with the email address and the public key
|
|
|
|
:param email: the email address of the requested contact
|
|
:param public_key: the public key of the requested contact
|
|
:return: the VCard string
|
|
"""
|
|
lines = [
|
|
"BEGIN:VCARD",
|
|
"VERSION:4.0",
|
|
f"EMAIL:{email}",
|
|
f"KEY:data:application/pgp-keys;base64,{public_key}",
|
|
"END:VCARD",
|
|
]
|
|
return "\n".join(lines)
|
|
|
|
|
|
def save_vcard(path: str, content: str):
|
|
"""Save the VCard string to the blob directory
|
|
|
|
:param path: the /tmp path of the .vcf file
|
|
:param content: the VCard content
|
|
"""
|
|
with open(path, "w+") as f:
|
|
f.write(content)
|