Python:GPG无收据加密
我已收到用于加密的公钥,但没有密钥收件人 问题:类型错误:应为str、bytes或os.PathLike对象,而不是NoneType 下面是气流的代码,我已经给出了Python:GPG无收据加密,python,encryption,gnupg,Python,Encryption,Gnupg,我已收到用于加密的公钥,但没有密钥收件人 问题:类型错误:应为str、bytes或os.PathLike对象,而不是NoneType 下面是气流的代码,我已经给出了key\u recipient=None,但它失败了 对于某些需求,我们得到了密钥接收者,它可以正常工作,但是这个需求没有密钥接收者 代码: class EncryptGPG(BaseOperator): @apply_defaults def __init__(self, s3_b
key\u recipient=None
,但它失败了
对于某些需求,我们得到了密钥接收者,它可以正常工作,但是这个需求没有密钥接收者
代码:
class EncryptGPG(BaseOperator):
@apply_defaults
def __init__(self,
s3_bucket,
s3_key,
key,
key_recipient=None,
*args,
**kwargs):
self.s3_bucket = s3_bucket
self.s3_key = s3_key
self.s3_conn_id = s3_conn_id
self.key_recipient = key_recipient
self.key = key
def encrypt_file(self, file_path, key_path , key_recipient):
"""Encrypt the file and Upload into s3"""
try:
gpg = gnupg.GPG()
key_data = base64.b64decode(key_path).decode()
import_result = gpg.import_keys(key_data)
with open(file_path, 'r+b') as f:
status = gpg.encrypt_file(
file=f,
recipients=[key_recipient],
output=f.name,
always_trust=True
)
也许我对Python的理解有些偏差,但您是否尝试过使用空列表而不是带有未提供的参数的列表而不是带有未提供参数的列表?是空列表,因为我没有收据