Metadata-Version: 2.2
Name: data_encrypter
Version: 1.0
Summary: A simple data encryption-decryption package for Django models.
Home-page: https://github.com/techbipin/data_encrypter.git
Author: Mr. Bipin Rajesh Tatkare
Author-email: techbipinrt2526@gmail.com
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django==5.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

```markdown
# data_encrypter

A simple Python package for encrypting and decrypting Django model instances using a password-derived key.  This package uses XOR encryption, base64 encoding, and pickling for serialization.

**Important Security Note:** This implementation is for demonstration and educational purposes.  For production systems, **strongly consider** using robust encryption libraries (like `cryptography`) and proper key management solutions.  XOR encryption is not considered secure for sensitive data in real-world applications.

## Installation

```bash
pip install data_encrypter
```

## Dependencies

This package requires Django.  It will be automatically installed when you install `data_encrypter`.

## Usage

1. **Import:**
   ```python
   from data_encrypter import DataEncrypter
   ```

2. **Create an instance of the encrypter:**
   ```python
   encrypter = DataEncrypter()
   ```

3. **Encrypt a model instance:**
   ```python
   from myapp.models import MyModel  # Replace with your model

   instance = MyModel.objects.get(pk=1) # Get the instance you want to encrypt
   password = "your_secret_password"  # **Use a strong, unique password!**

   encrypter.encrypt_model_instance(instance, password)
   ```

4. **Decrypt a model instance:**
   ```python
   from myapp.models import MyModel # Replace with your model

   instance = MyModel.objects.get(pk=1) # Get the instance you want to decrypt
   password = "your_secret_password"  # **Must be the same password used for encryption!**

   decrypted_fields = encrypter.decrypt_model_instance(instance, password)

   # Access the decrypted values (they are now on the instance)
   print(instance.some_field)
   print(instance.another_field)
   # ... and so on
   ```

**Important:** The `decrypt_model_instance` method *does not* automatically save the decrypted data back to the database.  If you want to save the changes, you need to call `instance.save()` yourself after decrypting.  For example:

```python
decrypted_fields = encrypter.decrypt_model_instance(instance, password)
instance.save(update_fields=decrypted_fields) # Save the changes
```

## Example

```python
from data_encrypter import DataEncrypter
from myapp.models import MyModel

encrypter = DataEncrypter()
password = "my_strong_password"

# Create a model instance (or get an existing one)
instance = MyModel(some_field="Some Value", another_field="Another Value")
instance.save()

# Encrypt
encrypter.encrypt_model_instance(instance, password)
print("Encrypted instance:", instance.some_field, instance.another_field) # These will be encrypted

# ... later, retrieve the instance from the database ...
instance = MyModel.objects.get(pk=instance.pk) # Refresh from DB

# Decrypt
encrypter.decrypt_model_instance(instance, password)
print("Decrypted instance:", instance.some_field, instance.another_field) # These will be decrypted

instance.save(update_fields=['some_field', 'another_field']) # Save the changes
```

## Contributing

Contributions are welcome!  Please open an issue or submit a pull request.

## License

MIT License (See `LICENSE` file for details)
```

This version keeps all the information within the same README.md file, without referring to separate modules or instructions.  It's self-contained and ready to be used as your README.md content.
