cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

PGP decryption in python file

TetianaDromova
New Contributor

The same decryption code works in notebook, but fails in python file:

 

import gnupg
from pyspark.dbutils import DBUtils

dbutils = DBUtils(spark)

gpg = gnupg.GPG()

decryption_key = dbutils.secrets.get(secret_scope, secret_name)
gpg.import_keys(decryption_key)

input_file_path = f"/Volumes/{catalog}/{schema}/{volume}/{folder}/{file}.csv.pgp"

with open(input_file_path, 'rb') as f:
    encrypted_data = f.read()

decrypted_data = gpg.decrypt(encrypted_data)

if decrypted_data.ok:
    print("Ok")

 

So, in notebook it's Ok. But In python file I receive WARNING:gnupg:FAILURE status emitted from gpg process: decrypt 4294967295. And the decrypted_data is empty.

0 REPLIES 0

Join Us as a Local Community Builder!

Passionate about hosting events and connecting people? Help us grow a vibrant local community—sign up today to get started!

Sign Up Now