mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 02:27:10 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			20 lines
		
	
	
		
			413 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			20 lines
		
	
	
		
			413 B
		
	
	
	
		
			Python
		
	
	
	
	
	
| import gnupg
 | |
| 
 | |
| from django.conf import settings
 | |
| 
 | |
| 
 | |
| class GnuPG:
 | |
|     """
 | |
|     A handy singleton to use when handling encrypted files.
 | |
|     """
 | |
| 
 | |
|     gpg = gnupg.GPG(gnupghome=settings.GNUPG_HOME)
 | |
| 
 | |
|     @classmethod
 | |
|     def decrypted(cls, file_handle, passphrase=None):
 | |
| 
 | |
|         if not passphrase:
 | |
|             passphrase = settings.PASSPHRASE
 | |
| 
 | |
|         return cls.gpg.decrypt_file(file_handle, passphrase=passphrase).data
 |