mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-04-02 13:45:10 -05:00
26 lines
584 B
Python
26 lines
584 B
Python
import gnupg
|
|
|
|
from django.conf import settings
|
|
|
|
|
|
class GnuPG(object):
|
|
"""
|
|
A handy singleton to use when handling encrypted files.
|
|
"""
|
|
|
|
gpg = gnupg.GPG(gnupghome=settings.GNUPG_HOME)
|
|
|
|
@classmethod
|
|
def decrypted(cls, file_handle):
|
|
return cls.gpg.decrypt_file(
|
|
file_handle, passphrase=settings.PASSPHRASE).data
|
|
|
|
@classmethod
|
|
def encrypted(cls, file_handle):
|
|
return cls.gpg.encrypt_file(
|
|
file_handle,
|
|
recipients=None,
|
|
passphrase=settings.PASSPHRASE,
|
|
symmetric=True
|
|
).data
|