【问题标题】:How to decrypt .pgp file stored in Google cloud storage?如何解密存储在谷歌云存储中的 .pgp 文件?
【发布时间】:2020-02-20 23:02:15
【问题描述】:

我有一个 .pgp 文件存储在 Google 云存储的存储桶中。 我想用私钥解密它并将其存储回 GCS 中的新目标文件夹。 有没有办法做到这一点?

【问题讨论】:

    标签: google-cloud-platform google-cloud-storage private-key pgp encryption-asymmetric


    【解决方案1】:

    无法直接在 Google Cloud Storage (GCS) 上进行更改,解密和保存文件需要下载文件,在本地解密并上传解密文件。

    我认为这段代码对您的用例很有用:

    from google.cloud import storage
    
    def download_blob(bucket_name, source_blob_name, local_file, destination_blob_name):
       #bucket_name = "your-bucket-name"
       #source_blob_name = "storage-object.pgp"
       #local_file = "local/storage-object.pgp"
    
       #Download your file from your bucket
       storage_client = storage.Client()
    
       bucket = storage_client.bucket(bucket_name)
       blob = bucket.blob(source_blob_name)
       blob.download_to_filename(local_file)
    
       # put your code to decrypt your file
    
       #Upload your decrypted file from local
       destination_blob_name= "/decrypted_files/storage-object.pgp"
       blob = bucket.blob(destination_blob_name)
       blob.upload_from_filename(local_file)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-12
      相关资源
      最近更新 更多