A simple django application provides function to encrypt password value with rsa public key before form submit and decrypt at the backend.
Project description
django-secure-password-input
A simple django application provides function to encrypt password value with rsa public key before form submit and decrypt at the backend.
Install
pip install django-secure-password-input
Usage
pro/settings.py
INSTALLED_APPS = [
...
'django_secure_password_input',
...
]
DJANGO_SECURE_PASSWORD_INPUT_RSA_PRIVATE_KEY = """-----BEGIN RSA PRIVATE KEY-----
......
-----END RSA PRIVATE KEY-----
"""
DJANGO_SECURE_PASSWORD_INPUT_ENCRYPTED_VALUE_PREFIX = "rsa-encrypted:"
Note:
-
Add your own DJANGO_SECURE_PASSWORD_INPUT_RSA_PRIVATE_KEY and keep it secret. You can generate rsa private key with rsa module in ipython. Copy all things between "BEGIN RSA PRIVATE KEY" and "END RSA PRIVATE KEY" and must include "BEGIN RSA PRIVATE KEY" and "END RSA PRIVATE KEY" lines. It will work if you not provide your own private key, it will use the django_secure_password_input's default private key, and it's not safe for you.
In [1]: import rsa In [2]: pk, sk = rsa.newkeys(4096) In [3]: print(sk.save_pkcs1().decode()) -----BEGIN RSA PRIVATE KEY----- MIIJNgIBAAKCAgEAnKTiU5t9xdjqp/dktzKBM9w70WFVUO0vZIY/BP8HHZCL13Mo 2L5Bld/AV6GbjpRFNLawI8n5rSqXyW+H8Sbh6ZhlPfNkdd4RBIiek6juxBAdkq3Q XPs/Kk435zokha+DFfAI3mu3ipLtECNdsIcbYt1FEFY9o+5qMhCTEyBV9aO36hlp NOpQL3rkeT0/a1MFfbb2jFTDdlXmfrRFyqGPufGCfzHwuy5jveedcjt62+Ahdb+v gYux+t5QRVUHcuCFQHk+z6gqgmis3YgII5lQD9XsSGa8pOoSiPaUDHJNikH958Q7 0OWVPlf7xWkzikGktph2Mtjb0Z0G87P4ZSrl//iLyKf4HQ09QZeV2LpiCeSGJySS 4qi2T82s01dqJIg4xNe2Xc+q8uFWzf/KOaELizT8F1+PwA1PZnLOHV4HARsP+yYN JTmV7/cWewulB1a+zov5iZsaE4QCgji8Q1pfPZYab9FQdfTO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vYXO0dPafAiOspZpm3n06kaM+N0fwWcue7ilmpac6 uuJUn0LqIWRb3qhFfvIppbDh3jVyWcCovJ5Jl7rzJsc9Es20AWN4VNIMC+3lMaN1 9+mC1KuoKP6A3ihnRMq8lKmg1EkLIQKCARBwpyErdMTWyjlLy82+tF5jODlu/2wz 0YakzZHVzWIsshx5yu/xc9CyJ4X/ANWLUBVkD8OgxS60LvR/ShfM6MV8fx499Qnv 5wBGcVpIh1S8xos92/dQhIae3r/VPy2T9YJnR1+j4cktd2NT2YRmU5MoLUmVJvvR Y8cZ9GjmKfHz3uQuqZ+7cGm2TQZdKhvDLtBesGCel8oG8I5Sf7lJV0G6qlYQWhso FimY/KITI8M77rcOFbFjN/Q38mvoa1ZevJ8RoLIsnIV5WoRXyyGOzljqePt+JE0G aQtN5YuCLFkOUvbLYrOIu2NhSf2PfF8AshfG9u0HBfdmTKg7tVvR0fhhdjKX3ub/ +H8oSvxWpAB+Kw== -----END RSA PRIVATE KEY----- In [4]:
app/admin.py
from django.contrib import admin
from django import forms
from django_secure_password_input.fields import DjangoSecurePasswordInput
from .models import Account
class AccountForm(forms.ModelForm):
password = DjangoSecurePasswordInput()
class Meta:
model = Account
exclude = []
class AccountAdmin(admin.ModelAdmin):
form = AccountForm
list_display = ["username", "password"]
admin.site.register(Account, AccountAdmin)
Note:
- Create a form, and override password field using type DjangoSecurePasswordInput.
Release
v0.1.0
- First release. |
v0.1.1
- No depends on django-static-jquery3.
v0.1.2
- Doc update.
- Add License file.
v0.1.3
- Fix problems in django 3.2.x.
v0.1.4
- Let the end user to choose the package's version.
v0.1.5
- Doc update.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-secure-password-input-0.1.5.tar.gz
.
File metadata
- Download URL: django-secure-password-input-0.1.5.tar.gz
- Upload date:
- Size: 66.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fff6ee7f8f1db74e3a80822989acc3a3a168db3936369797b4382debdb50d10 |
|
MD5 | f4516825524ffd9cc1fa585b011cdb6d |
|
BLAKE2b-256 | 0f323cfab18fff8049ce45a63d110a4fb52e7f7f4958550b96074a58b8b57117 |
File details
Details for the file django_secure_password_input-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: django_secure_password_input-0.1.5-py3-none-any.whl
- Upload date:
- Size: 64.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b07d184873d9f273657401d11d9fa532006a201ca40d800483f6046b2d4af031 |
|
MD5 | d9832b4c0e52a76a3923e8f44edc57bc |
|
BLAKE2b-256 | 669c70432a89da53725753ebe386c7e66cdeaf2dbdf3354c7724fa62b5ce0bf7 |