mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-12-16 19:46:48 +01:00
25 lines
543 B
Python
25 lines
543 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, path):
|
||
|
|
return cls.gpg.decrypt_file(path, passphrase=settings.PASSPHRASE).data
|
||
|
|
|
||
|
|
@classmethod
|
||
|
|
def encrypted(cls, path):
|
||
|
|
return cls.gpg.encrypt_file(
|
||
|
|
path,
|
||
|
|
recipients=None,
|
||
|
|
passphrase=settings.PASSPHRASE,
|
||
|
|
symmetric=True
|
||
|
|
).data
|