https://github.com/ruddra/django-encrypt-file
A simple package to encrypt Django's uploaded or downloading files
https://github.com/ruddra/django-encrypt-file
django django-file django-framework encryption file python
Last synced: about 2 months ago
JSON representation
A simple package to encrypt Django's uploaded or downloading files
- Host: GitHub
- URL: https://github.com/ruddra/django-encrypt-file
- Owner: ruddra
- License: mit
- Created: 2017-01-06T20:47:12.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-08T04:11:17.000Z (over 6 years ago)
- Last Synced: 2025-02-04T22:36:08.898Z (11 months ago)
- Topics: django, django-file, django-framework, encryption, file, python
- Language: Python
- Size: 23.4 KB
- Stars: 5
- Watchers: 5
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.rst
- License: license.txt
Awesome Lists containing this project
README
Django File Encrypt
~~~~~~~~~~~~~~~~~~~
|Build Status|
.. |Build Status| image:: https://travis-ci.org/travis-ci/travis-web.svg?branch=master
:target: https://travis-ci.org/travis-ci/travis-web
|image0|
.. |image0| image:: https://img.shields.io/pypi/v/djangoencryptfile.svg
:target: https://pypi.python.org/pypi/djangoencryptfile
.. image:: https://landscape.io/github/ruddra/django-encrypt-file/master/landscape.svg?style=flat
:target: https://landscape.io/github/ruddra/django-encrypt-file/master
:alt: Code Health
This package can be used to encrypt Django’s in memory files to encrypt
them.
Status
~~~~~~
This package is no longer maintained. So use at your own risk.
Documentation
~~~~~~~~~~~~~
Go to this url: https://ruddra.com/documentation-of-django-encrypt-file/
Download
~~~~~~~~
Use ``pip install djangoencryptfile``
Basic Usage:
------------
::
from djangoencryptfile import EncryptionService
from django.core.files import File
password = '1234'
service = EncryptionService(raise_exception=False)
open('readme.md', 'rb') as inputfile:
usefile = File(inputfile, name='readme.md')
encrypted_file = service.encrypt_file(useFile, password, extension='enc') # it will save readme.md.enc
decrypt_file = service.decrypt_file(encrypted_file, password, extension='enc') # it will remove .enc extension
Using in Views:
~~~~~~~~~~~~~~~
::
from django_encrypt_file import EncryptionService, ValidationError
def some_view(request):
try:
myfile = request.FILES.get('myfile', None)
password = request.POST.get('password', None)
encrypted_file = EncryptionService().encrypt_file(myfile, password, extension='enc')
decrypt_file = service.decrypt_file(encrypted_file, password, extension='enc') # it will remove .enc extension
except ValidationError as e:
print(e)
Input file here can be any kind of Django File Object like
``models.FileField`` or ``forms.FileFiled``.
raise\_exception will throw ``ValidationError`` error which can be
imported ``from django_encrypt_file import ValidationError``