```markdown
# Image Vault
Image Vault is a tool for encrypting and decrypting image files. It allows you to securely split images into multiple encrypted parts and then reassemble them. The project leverages AES encryption to ensure the security of your image files.
## Features
- Encrypt images by splitting them into multiple parts.
- Decrypt images and reassemble them from encrypted parts.
- Supports customizable number of parts for splitting.
- Uses AES encryption for secure data handling.
## Requirements
- Python 3.x
- Required Python packages:
- `cryptography`
- `pillow`
- `click`
You can install the required packages using pip:
```bash
pip install cryptography pillow click
```
## Usage
The main script provides a command-line interface with options for encryption and decryption.
### Encrypting a Folder of Images
To encrypt a folder of images, use the `--encrypt` flag. You can specify the input path, output path, key, and number of parts for splitting:
```bash
fs --encrypt --input_path ./path/to/images --output_path ./path/to/output --key your_key --parts 4
```
### Decrypting a Folder of Encrypted Images
To decrypt a folder of encrypted images, use the `--decrypt` flag. You only need to specify the input path and the key:
```bash
fs --decrypt --input_path ./path/to/encrypted --key your_key
```
### Command Line Options
- `--encrypt`: Use this flag for encryption.
- `--decrypt`: Use this flag for decryption.
- `--input_path`: Path to the input directory. Default is `./`.
- `--output_path`: Path to the output directory. Default is `./op`.
- `--key`: Encryption/Decryption key. Default is `1234`.
- `--parts`: Number of parts to split the file into for encryption. Default is `1`.
## Example
Encrypting an image folder:
```bash
python script.py --encrypt --input_path ./test_images --output_path ./encrypted_images --key mysecretkey --parts 4
```
Decrypting an image folder:
```bash
python script.py --decrypt --input_path ./encrypted_images --key mysecretkey
```
## Implementation Details
### Key Generation
A key is generated from a seed token using SHA-256 hashing:
```python
def key_gen(seed):
seed = bytes(seed, "utf-8")
seed_hash = hashlib.sha256()
seed_hash.update(seed)
return seed_hash.hexdigest()
```
### Encryption
Images are split into parts, each part is padded, and then encrypted using AES in CBC mode:
```python
def encrypt_file(f_name, file_number, input_file, seed_token):
key = seed_token.ljust(32)[:32].encode('utf-8')
iv = os.urandom(16)
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
encryptor = cipher.encryptor()
data = input_file
padder = padding.PKCS7(algorithms.AES.block_size).padder()
padded_data = padder.update(data) + padder.finalize()
encrypted_data = encryptor.update(padded_data) + encryptor.finalize()
hex_data = binascii.hexlify(iv + encrypted_data).decode('utf-8')
with open(f'{f_name}{file_number}', 'w') as output_file:
output_file.write(hex_data)
print(f"Encrypted data written to {f_name}{file_number}")
```
### Decryption
The encrypted parts are read, decrypted, and reassembled into the original image:
```python
def decrypt_file(input_file, seed_token):
key = seed_token.ljust(32)[:32].encode('utf-8')
hex_data = input_file
encrypted_data_with_iv = binascii.unhexlify(hex_data)
iv = encrypted_data_with_iv[:16]
encrypted_data = encrypted_data_with_iv[16:]
cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())
decryptor = cipher.decryptor()
padded_data = decryptor.update(encrypted_data) + decryptor.finalize()
unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()
data = unpadder.update(padded_data) + unpadder.finalize()
print("Decrypted data")
return data
```
Raw data
{
"_id": null,
"home_page": null,
"name": "image-vault",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "python, cryptography, image_vault, vault, encrypt, encryption, fs",
"author": "Tanish",
"author_email": "sharmatanish0907@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/64/e5/c2886d6daa4f394329b809ec263f6ca049c4af980899a52c5f57906e70d8/image_vault-1.0.2.tar.gz",
"platform": null,
"description": "```markdown\n# Image Vault\n\nImage Vault is a tool for encrypting and decrypting image files. It allows you to securely split images into multiple encrypted parts and then reassemble them. The project leverages AES encryption to ensure the security of your image files.\n\n## Features\n\n- Encrypt images by splitting them into multiple parts.\n- Decrypt images and reassemble them from encrypted parts.\n- Supports customizable number of parts for splitting.\n- Uses AES encryption for secure data handling.\n\n## Requirements\n\n- Python 3.x\n- Required Python packages:\n - `cryptography`\n - `pillow`\n - `click`\n\nYou can install the required packages using pip:\n\n```bash\npip install cryptography pillow click\n```\n\n## Usage\n\nThe main script provides a command-line interface with options for encryption and decryption.\n\n### Encrypting a Folder of Images\n\nTo encrypt a folder of images, use the `--encrypt` flag. You can specify the input path, output path, key, and number of parts for splitting:\n\n```bash\nfs --encrypt --input_path ./path/to/images --output_path ./path/to/output --key your_key --parts 4\n```\n\n### Decrypting a Folder of Encrypted Images\n\nTo decrypt a folder of encrypted images, use the `--decrypt` flag. You only need to specify the input path and the key:\n\n```bash\nfs --decrypt --input_path ./path/to/encrypted --key your_key\n```\n\n### Command Line Options\n\n- `--encrypt`: Use this flag for encryption.\n- `--decrypt`: Use this flag for decryption.\n- `--input_path`: Path to the input directory. Default is `./`.\n- `--output_path`: Path to the output directory. Default is `./op`.\n- `--key`: Encryption/Decryption key. Default is `1234`.\n- `--parts`: Number of parts to split the file into for encryption. Default is `1`.\n\n## Example\n\nEncrypting an image folder:\n\n```bash\npython script.py --encrypt --input_path ./test_images --output_path ./encrypted_images --key mysecretkey --parts 4\n```\n\nDecrypting an image folder:\n\n```bash\npython script.py --decrypt --input_path ./encrypted_images --key mysecretkey\n```\n\n## Implementation Details\n\n### Key Generation\n\nA key is generated from a seed token using SHA-256 hashing:\n\n```python\ndef key_gen(seed):\n seed = bytes(seed, \"utf-8\")\n seed_hash = hashlib.sha256()\n seed_hash.update(seed)\n return seed_hash.hexdigest()\n```\n\n### Encryption\n\nImages are split into parts, each part is padded, and then encrypted using AES in CBC mode:\n\n```python\ndef encrypt_file(f_name, file_number, input_file, seed_token):\n key = seed_token.ljust(32)[:32].encode('utf-8')\n iv = os.urandom(16)\n cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())\n encryptor = cipher.encryptor()\n data = input_file\n padder = padding.PKCS7(algorithms.AES.block_size).padder()\n padded_data = padder.update(data) + padder.finalize()\n encrypted_data = encryptor.update(padded_data) + encryptor.finalize()\n hex_data = binascii.hexlify(iv + encrypted_data).decode('utf-8')\n with open(f'{f_name}{file_number}', 'w') as output_file:\n output_file.write(hex_data)\n print(f\"Encrypted data written to {f_name}{file_number}\")\n```\n\n### Decryption\n\nThe encrypted parts are read, decrypted, and reassembled into the original image:\n\n```python\ndef decrypt_file(input_file, seed_token):\n key = seed_token.ljust(32)[:32].encode('utf-8')\n hex_data = input_file\n encrypted_data_with_iv = binascii.unhexlify(hex_data)\n iv = encrypted_data_with_iv[:16]\n encrypted_data = encrypted_data_with_iv[16:]\n cipher = Cipher(algorithms.AES(key), modes.CBC(iv), backend=default_backend())\n decryptor = cipher.decryptor()\n padded_data = decryptor.update(encrypted_data) + decryptor.finalize()\n unpadder = padding.PKCS7(algorithms.AES.block_size).unpadder()\n data = unpadder.update(padded_data) + unpadder.finalize()\n print(\"Decrypted data\")\n return data\n```\n\n",
"bugtrack_url": null,
"license": null,
"summary": "it is a tool for encrypting images",
"version": "1.0.2",
"project_urls": null,
"split_keywords": [
"python",
" cryptography",
" image_vault",
" vault",
" encrypt",
" encryption",
" fs"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "763aea1dc74c7a4ee4fb74e0f6863748a3bf5c7be11676b2c7f6712c111f8181",
"md5": "1318cfde659a487e997cfa00174dd227",
"sha256": "c4c82104d536445f671cdb6bf7ba9757a2472b7a41ecc6cd5f924a621062405b"
},
"downloads": -1,
"filename": "image_vault-1.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "1318cfde659a487e997cfa00174dd227",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 5543,
"upload_time": "2024-07-30T15:35:37",
"upload_time_iso_8601": "2024-07-30T15:35:37.812456Z",
"url": "https://files.pythonhosted.org/packages/76/3a/ea1dc74c7a4ee4fb74e0f6863748a3bf5c7be11676b2c7f6712c111f8181/image_vault-1.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "64e5c2886d6daa4f394329b809ec263f6ca049c4af980899a52c5f57906e70d8",
"md5": "8479301679b5ecc83022f7d468bdb63c",
"sha256": "b5515a486d3479f7141fc2d9b4a8f2b05b7b3d3d771d06d6ddc1ac1ca9c03cf0"
},
"downloads": -1,
"filename": "image_vault-1.0.2.tar.gz",
"has_sig": false,
"md5_digest": "8479301679b5ecc83022f7d468bdb63c",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4839,
"upload_time": "2024-07-30T15:35:39",
"upload_time_iso_8601": "2024-07-30T15:35:39.469181Z",
"url": "https://files.pythonhosted.org/packages/64/e5/c2886d6daa4f394329b809ec263f6ca049c4af980899a52c5f57906e70d8/image_vault-1.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-07-30 15:35:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "image-vault"
}