cryptshield 1.1.0__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptshield
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Secure Encryption and Deletion Application
5
5
  Author: Wilmer Martinez
6
6
  License: MIT License
@@ -30,7 +30,7 @@ Project-URL: Documentation, https://github.com/wilmerm/cryptshield?tab=readme-ov
30
30
  Project-URL: Repository, https://github.com/wilmerm/cryptshield
31
31
  Project-URL: Issues, https://github.com/wilmerm/cryptshield/issues
32
32
  Project-URL: Release, https://github.com/wilmerm/cryptshield/releases
33
- Keywords: encryption,deletion,secure,application,python,cryptography,cryptshield,guardian
33
+ Keywords: encryption,deletion,secure,application,python,cryptography,cryptshield,guardian,privacy,security,file,folder,data,protection,safety,safeguard,lock,unlock,erase,wipe,shred,scrub,clean,destroy,confidential,sensitive,information,safekeeping,cybersecurity
34
34
  Classifier: Development Status :: 5 - Production/Stable
35
35
  Classifier: Intended Audience :: Developers
36
36
  Classifier: Topic :: Security :: Cryptography
@@ -46,6 +46,7 @@ Requires-Python: >=3.10
46
46
  Description-Content-Type: text/markdown
47
47
  License-File: LICENSE
48
48
  Requires-Dist: cryptography
49
+ Requires-Dist: Pillow
49
50
  Dynamic: license-file
50
51
 
51
52
  # Secure Encryption, Deletion, and Metadata Cleaning Application
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cryptshield"
7
- version = "1.1.0"
7
+ version = "1.1.1"
8
8
  authors = [
9
9
  { name = "Wilmer Martinez" }
10
10
  ]
@@ -38,7 +38,8 @@ classifiers = [# https://pypi.org/classifiers/
38
38
  "Programming Language :: Python :: 3.13",
39
39
  ]
40
40
  dependencies = [
41
- "cryptography",
41
+ "cryptography",
42
+ "Pillow",
42
43
  ]
43
44
  keywords = [
44
45
  "encryption",
@@ -49,6 +50,27 @@ keywords = [
49
50
  "cryptography",
50
51
  "cryptshield",
51
52
  "guardian",
53
+ "privacy",
54
+ "security",
55
+ "file",
56
+ "folder",
57
+ "data",
58
+ "protection",
59
+ "safety",
60
+ "safeguard",
61
+ "lock",
62
+ "unlock",
63
+ "erase",
64
+ "wipe",
65
+ "shred",
66
+ "scrub",
67
+ "clean",
68
+ "destroy",
69
+ "confidential",
70
+ "sensitive",
71
+ "information",
72
+ "safekeeping",
73
+ "cybersecurity"
52
74
  ]
53
75
 
54
76
  [project.urls]
@@ -62,4 +84,5 @@ Release = "https://github.com/wilmerm/cryptshield/releases"
62
84
  where = ["src"]
63
85
  include = ["cryptshield"]
64
86
 
65
-
87
+ [project.scripts]
88
+ cryptshield = "cryptshield.cryptshield:main"
@@ -2,11 +2,12 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="cryptshield",
5
- version="1.1.0",
5
+ version="1.1.1",
6
6
  packages=find_packages(where="src"),
7
7
  package_dir={"": "src"},
8
8
  install_requires=[
9
9
  "cryptography",
10
+ "Pillow",
10
11
  ],
11
12
  entry_points={
12
13
  "console_scripts": [
@@ -0,0 +1,4 @@
1
+ __version__ = "1.1.1"
2
+
3
+
4
+ from .cryptshield import *
@@ -1,4 +1,5 @@
1
1
  import logging
2
+ from pathlib import Path
2
3
  import sys
3
4
  import os
4
5
  import subprocess
@@ -144,23 +145,27 @@ def encrypt(path: str, key: str, delete: bool = True):
144
145
  return
145
146
 
146
147
  if os.path.isdir(path):
148
+ # Preparar variables
149
+ dir_path = Path(path)
150
+ parent_dir = dir_path.parent
151
+ dir_name = dir_path.name
147
152
 
148
- # First, compress the directory into a ZIP file
153
+ # Comprimir el directorio
149
154
  logger.info(f'Compressing directory "{path}"...')
150
- subprocess.run(['zip', '-r', f'{path}.zip', path], check=True)
155
+ subprocess.run(['zip', '-r', f'{dir_path}.zip', dir_name], cwd=parent_dir, check=True)
151
156
 
152
157
  # Encrypt the ZIP file
153
- encrypt(f'{path}.zip', key, delete=False)
158
+ encrypt(f'{dir_path}.zip', key, delete=False)
154
159
 
155
- # Rename the encrypted ZIP file to '.zipencrypted'.
156
- os.rename(f'{path}.zip.{ENCRYPTED}', f'{path}.{ZIPENCRYPTED}')
160
+ # Rename the encrypted ZIP file
161
+ os.rename(f'{dir_path}.zip.{ENCRYPTED}', f'{dir_path}.{ZIPENCRYPTED}')
157
162
 
158
- # Delete the original directory and ZIP file
159
- logger.info(f'Deleting "{path}.zip"...')
160
- secure_delete(f'{path}.zip')
163
+ # Delete original ZIP and directory
164
+ logger.info(f'Deleting "{dir_path}.zip"...')
165
+ secure_delete(f'{dir_path}.zip')
161
166
  if delete:
162
- logger.info(f'Deleting "{path}"...')
163
- secure_delete(path)
167
+ logger.info(f'Deleting "{dir_path}"...')
168
+ secure_delete(dir_path)
164
169
 
165
170
  elif os.path.isfile(path) or os.path.islink(path):
166
171
  logger.info(f'Encrypting "{path}"...')
@@ -425,20 +430,20 @@ def confirm(prompt: str) -> bool:
425
430
  def clean_file_metadata(*args):
426
431
  """
427
432
  Clean metadata from files while preserving primary functionality.
428
-
433
+
429
434
  This function removes metadata from various file formats including:
430
435
  - Images: EXIF, GPS, camera info, comments
431
436
  - Documents: Author, creation date, edit history, comments
432
437
  - Multimedia: ID3 tags, artist, album, etc.
433
438
  - PDFs: Document properties, metadata, annotations
434
439
  """
435
-
440
+
436
441
  # Parse command line arguments
437
442
  file_paths = []
438
443
  preserve_essential = False
439
444
  backup = True
440
445
  verify = True
441
-
446
+
442
447
  for arg in args:
443
448
  # Check if it's a boolean-like argument
444
449
  if isinstance(arg, str):
@@ -458,23 +463,23 @@ def clean_file_metadata(*args):
458
463
  else: # Third is verify
459
464
  verify = False
460
465
  continue
461
-
466
+
462
467
  # Otherwise, treat as file path
463
468
  file_paths.append(arg)
464
-
469
+
465
470
  # If we got boolean arguments, we need to re-parse correctly
466
471
  # Arguments order: file_paths... preserve_essential backup verify
467
472
  if len(args) > 1:
468
473
  # Check if last few arguments are booleans
469
474
  bool_args = []
470
475
  file_args = list(args)
471
-
476
+
472
477
  # Process from the end to find boolean arguments
473
478
  while file_args and isinstance(file_args[-1], str) and file_args[-1].lower() in ('true', 'false', 'yes', 'no', '1', '0', 'on', 'off'):
474
479
  bool_args.insert(0, file_args.pop())
475
-
480
+
476
481
  file_paths = file_args
477
-
482
+
478
483
  # Parse boolean arguments
479
484
  if len(bool_args) >= 1:
480
485
  preserve_essential = bool_args[0].lower() in ('true', 'yes', '1', 'on')
@@ -482,16 +487,16 @@ def clean_file_metadata(*args):
482
487
  backup = bool_args[1].lower() in ('true', 'yes', '1', 'on')
483
488
  if len(bool_args) >= 3:
484
489
  verify = bool_args[2].lower() in ('true', 'yes', '1', 'on')
485
-
490
+
486
491
  expanded_paths = expand_path(file_paths)
487
-
492
+
488
493
  if not expanded_paths:
489
494
  logger.error("No valid files found to process.")
490
495
  return
491
-
496
+
492
497
  logger.info(f"Starting metadata cleaning for {len(expanded_paths)} files...")
493
498
  logger.info(f"Settings: preserve_essential={preserve_essential}, backup={backup}, verify={verify}")
494
-
499
+
495
500
  results = clean_metadata(
496
501
  *expanded_paths,
497
502
  preserve_essential=preserve_essential,
@@ -499,26 +504,26 @@ def clean_file_metadata(*args):
499
504
  verify=verify,
500
505
  logger=logger
501
506
  )
502
-
507
+
503
508
  # Summary statistics
504
509
  successful = sum(1 for r in results if r.success)
505
510
  verified = sum(1 for r in results if r.verified)
506
511
  failed = len(results) - successful
507
-
512
+
508
513
  logger.info(f"Metadata cleaning completed:")
509
514
  logger.info(f" Successful: {successful}/{len(results)}")
510
515
  if verify:
511
516
  logger.info(f" Verified: {verified}/{successful}")
512
517
  if failed > 0:
513
518
  logger.info(f" Failed: {failed}")
514
-
519
+
515
520
  # List failed files
516
521
  failed_files = [r for r in results if not r.success]
517
522
  if failed_files:
518
523
  logger.error("Failed to clean metadata from:")
519
524
  for result in failed_files:
520
525
  logger.error(f" {result.file_path}: {result.error}")
521
-
526
+
522
527
  # Audit summary
523
528
  total_metadata_removed = sum(len(r.metadata_removed) for r in results if r.success)
524
529
  logger.info(f"AUDIT SUMMARY: Removed {total_metadata_removed} metadata entries from {successful} files")
@@ -551,14 +556,14 @@ def show_help():
551
556
  decrypt_text <text> <key>: Decrypt encrypted text using a key.
552
557
  clean_metadata <path>... [preserve_essential] [backup] [verify]: Clean metadata from files.
553
558
  help: Show this help message.
554
-
559
+
555
560
  Examples:
556
561
  # Clean metadata from files
557
562
  cryptshield clean_metadata /path/to/image.jpg /path/to/document.pdf
558
-
563
+
559
564
  # Clean metadata with essential preservation
560
565
  cryptshield clean_metadata /path/to/file.jpg true true true
561
-
566
+
562
567
  # Clean without backup (not recommended)
563
568
  cryptshield clean_metadata /path/to/file.pdf false false true
564
569
  """
@@ -1,13 +1,13 @@
1
1
  """
2
2
  Metadata Cleaner Module for Cryptshield
3
3
 
4
- This module provides secure metadata deletion functionality that complies with
4
+ This module provides secure metadata deletion functionality that complies with
5
5
  DoD 5220.22-M standards. It removes metadata from various file formats while
6
6
  preserving the primary functionality of files.
7
7
 
8
8
  Supported formats:
9
9
  - Images: JPEG, PNG, TIFF, GIF
10
- - Documents: PDF, DOCX, XLSX, PPTX
10
+ - Documents: PDF, DOCX, XLSX, PPTX
11
11
  - Multimedia: MP3, MP4, AVI, MOV
12
12
  - Text: TXT, RTF
13
13
 
@@ -30,7 +30,6 @@ import mimetypes
30
30
  try:
31
31
  from PIL import Image
32
32
  from PIL.ExifTags import TAGS
33
- import piexif
34
33
  PILLOW_AVAILABLE = True
35
34
  except ImportError:
36
35
  PILLOW_AVAILABLE = False
@@ -73,8 +72,8 @@ class MetadataCleanerError(Exception):
73
72
 
74
73
  class MetadataCleanResult:
75
74
  """Class to hold the results of metadata cleaning operation"""
76
-
77
- def __init__(self, file_path: str, success: bool = False,
75
+
76
+ def __init__(self, file_path: str, success: bool = False,
78
77
  metadata_removed: Optional[Dict[str, Any]] = None,
79
78
  metadata_preserved: Optional[Dict[str, Any]] = None,
80
79
  error: Optional[str] = None):
@@ -90,80 +89,82 @@ class MetadataCleaner:
90
89
  """
91
90
  Main class for cleaning metadata from various file formats
92
91
  """
93
-
92
+
94
93
  def __init__(self, logger: Optional[logging.Logger] = None):
95
94
  self.logger = logger or logging.getLogger(__name__)
96
95
  self.supported_formats = {
97
96
  # Images
98
97
  '.jpg', '.jpeg', '.png', '.tiff', '.tif', '.gif',
99
- # Documents
98
+ # Documents
100
99
  '.pdf', '.docx', '.xlsx', '.pptx',
101
100
  # Multimedia
102
101
  '.mp3', '.mp4', '.avi', '.mov', '.wav', '.flac',
103
102
  # Text
104
103
  '.txt', '.rtf'
105
104
  }
106
-
105
+
107
106
  # Default metadata to preserve (can be configured)
108
107
  self.preserve_essential = {
109
108
  'images': ['format', 'size', 'mode'],
110
109
  'documents': ['title', 'creator'], # Only if explicitly requested
111
110
  'multimedia': ['duration', 'bitrate'], # Only if explicitly requested
112
111
  }
113
-
114
- def clean_metadata(self, file_paths: List[str],
112
+
113
+ def clean_metadata(self, file_paths: List[str],
115
114
  preserve_essential: bool = False,
116
115
  backup: bool = True,
117
116
  verify: bool = True) -> List[MetadataCleanResult]:
118
117
  """
119
118
  Clean metadata from multiple files
120
-
119
+
121
120
  Args:
122
121
  file_paths: List of file paths to clean
123
122
  preserve_essential: Whether to preserve essential metadata
124
123
  backup: Whether to create backups before cleaning
125
124
  verify: Whether to verify metadata removal
126
-
125
+
127
126
  Returns:
128
127
  List of MetadataCleanResult objects
129
128
  """
130
129
  results = []
131
-
130
+
132
131
  for file_path in file_paths:
133
132
  self.logger.info(f"Processing file: {file_path}")
134
-
133
+
135
134
  try:
136
135
  result = self._clean_single_file(
137
136
  file_path, preserve_essential, backup, verify
138
137
  )
139
138
  results.append(result)
140
-
139
+
141
140
  if result.success:
142
141
  self.logger.info(f"Successfully cleaned metadata from: {file_path}")
143
142
  if result.metadata_removed:
144
- self.logger.info(f"Removed metadata: {list(result.metadata_removed.keys())}")
143
+ self.logger.info(f"Removed metadata details:")
144
+ for key, value in result.metadata_removed.items():
145
+ self.logger.info(f" - {key}: {value}")
145
146
  else:
146
147
  self.logger.error(f"Failed to clean metadata from: {file_path}")
147
148
  if result.error:
148
149
  self.logger.error(f"Error: {result.error}")
149
-
150
+
150
151
  except Exception as e:
151
152
  error_msg = f"Unexpected error processing {file_path}: {str(e)}"
152
153
  self.logger.error(error_msg)
153
154
  results.append(MetadataCleanResult(file_path, success=False, error=error_msg))
154
-
155
+
155
156
  return results
156
-
157
+
157
158
  def _clean_single_file(self, file_path: str, preserve_essential: bool,
158
159
  backup: bool, verify: bool) -> MetadataCleanResult:
159
160
  """Clean metadata from a single file"""
160
-
161
+
161
162
  if not os.path.exists(file_path):
162
163
  return MetadataCleanResult(
163
- file_path, success=False,
164
+ file_path, success=False,
164
165
  error=f"File does not exist: {file_path}"
165
166
  )
166
-
167
+
167
168
  # Check if file format is supported
168
169
  file_ext = Path(file_path).suffix.lower()
169
170
  if file_ext not in self.supported_formats:
@@ -171,7 +172,7 @@ class MetadataCleaner:
171
172
  file_path, success=False,
172
173
  error=f"Unsupported file format: {file_ext}"
173
174
  )
174
-
175
+
175
176
  # Create backup if requested
176
177
  backup_path = None
177
178
  if backup:
@@ -184,23 +185,23 @@ class MetadataCleaner:
184
185
  file_path, success=False,
185
186
  error=f"Failed to create backup: {str(e)}"
186
187
  )
187
-
188
+
188
189
  try:
189
190
  # Get original metadata for logging
190
191
  original_metadata = self._extract_metadata(file_path)
191
-
192
+
192
193
  # Clean metadata based on file type
193
194
  result = self._clean_by_type(file_path, file_ext, preserve_essential)
194
-
195
+
195
196
  if result.success and verify:
196
197
  # Verify metadata removal
197
198
  result.verified = self._verify_metadata_removal(file_path, original_metadata)
198
199
  if not result.verified:
199
200
  self.logger.warning(f"Verification failed for: {file_path}")
200
-
201
+
201
202
  # Log audit information
202
203
  self._log_audit(file_path, result, original_metadata)
203
-
204
+
204
205
  # Remove backup if cleaning was successful and verification passed
205
206
  if result.success and backup_path and (not verify or result.verified):
206
207
  try:
@@ -208,9 +209,9 @@ class MetadataCleaner:
208
209
  self.logger.debug(f"Removed backup: {backup_path}")
209
210
  except Exception as e:
210
211
  self.logger.warning(f"Failed to remove backup {backup_path}: {str(e)}")
211
-
212
+
212
213
  return result
213
-
214
+
214
215
  except Exception as e:
215
216
  # Restore from backup if available
216
217
  if backup_path and os.path.exists(backup_path):
@@ -220,55 +221,55 @@ class MetadataCleaner:
220
221
  self.logger.info(f"Restored from backup: {file_path}")
221
222
  except Exception as restore_error:
222
223
  self.logger.error(f"Failed to restore backup: {str(restore_error)}")
223
-
224
+
224
225
  return MetadataCleanResult(
225
226
  file_path, success=False,
226
227
  error=f"Error cleaning metadata: {str(e)}"
227
228
  )
228
-
229
- def _clean_by_type(self, file_path: str, file_ext: str,
229
+
230
+ def _clean_by_type(self, file_path: str, file_ext: str,
230
231
  preserve_essential: bool) -> MetadataCleanResult:
231
232
  """Clean metadata based on file type"""
232
-
233
+
233
234
  # Image files
234
235
  if file_ext in ['.jpg', '.jpeg', '.png', '.tiff', '.tif', '.gif']:
235
236
  return self._clean_image_metadata(file_path, preserve_essential)
236
-
237
+
237
238
  # PDF files
238
239
  elif file_ext == '.pdf':
239
240
  return self._clean_pdf_metadata(file_path, preserve_essential)
240
-
241
+
241
242
  # Office documents
242
243
  elif file_ext in ['.docx', '.xlsx', '.pptx']:
243
244
  return self._clean_office_metadata(file_path, file_ext, preserve_essential)
244
-
245
+
245
246
  # Multimedia files
246
247
  elif file_ext in ['.mp3', '.mp4', '.avi', '.mov', '.wav', '.flac']:
247
248
  return self._clean_multimedia_metadata(file_path, preserve_essential)
248
-
249
+
249
250
  # Text files (limited metadata)
250
251
  elif file_ext in ['.txt', '.rtf']:
251
252
  return self._clean_text_metadata(file_path, preserve_essential)
252
-
253
+
253
254
  else:
254
255
  return MetadataCleanResult(
255
256
  file_path, success=False,
256
257
  error=f"No cleaner available for file type: {file_ext}"
257
258
  )
258
-
259
+
259
260
  def _clean_image_metadata(self, file_path: str, preserve_essential: bool) -> MetadataCleanResult:
260
261
  """Clean metadata from image files"""
261
-
262
+
262
263
  if not PILLOW_AVAILABLE:
263
264
  return MetadataCleanResult(
264
265
  file_path, success=False,
265
266
  error="PIL/Pillow not available for image processing"
266
267
  )
267
-
268
+
268
269
  try:
269
270
  # Extract original metadata
270
271
  original_metadata = {}
271
-
272
+
272
273
  with Image.open(file_path) as img:
273
274
  # Get EXIF data
274
275
  if hasattr(img, '_getexif') and img._getexif():
@@ -276,7 +277,7 @@ class MetadataCleaner:
276
277
  for tag_id, value in exif_data.items():
277
278
  tag = TAGS.get(tag_id, tag_id)
278
279
  original_metadata[tag] = value
279
-
280
+
280
281
  # Preserve essential image properties
281
282
  preserved = {}
282
283
  if preserve_essential:
@@ -285,125 +286,125 @@ class MetadataCleaner:
285
286
  'size': img.size,
286
287
  'mode': img.mode
287
288
  }
288
-
289
+
289
290
  # Create new image without metadata
290
291
  # Convert to RGB if necessary (for JPEG)
291
292
  if img.mode in ('RGBA', 'LA', 'P') and file_path.lower().endswith(('.jpg', '.jpeg')):
292
293
  img = img.convert('RGB')
293
-
294
+
294
295
  # Save without metadata
295
296
  save_kwargs = {}
296
297
  if img.format == 'JPEG':
297
298
  save_kwargs['exif'] = b"" # Empty EXIF data
298
299
  elif img.format == 'PNG':
299
300
  save_kwargs['pnginfo'] = None # Remove PNG info
300
-
301
+
301
302
  img.save(file_path, **save_kwargs)
302
-
303
+
303
304
  return MetadataCleanResult(
304
305
  file_path, success=True,
305
306
  metadata_removed=original_metadata,
306
307
  metadata_preserved=preserved
307
308
  )
308
-
309
+
309
310
  except Exception as e:
310
311
  return MetadataCleanResult(
311
312
  file_path, success=False,
312
313
  error=f"Failed to clean image metadata: {str(e)}"
313
314
  )
314
-
315
+
315
316
  def _clean_pdf_metadata(self, file_path: str, preserve_essential: bool) -> MetadataCleanResult:
316
317
  """Clean metadata from PDF files"""
317
-
318
+
318
319
  if not PDF_AVAILABLE:
319
320
  return MetadataCleanResult(
320
321
  file_path, success=False,
321
322
  error="PyPDF2 not available for PDF processing"
322
323
  )
323
-
324
+
324
325
  try:
325
326
  original_metadata = {}
326
327
  preserved = {}
327
-
328
+
328
329
  with open(file_path, 'rb') as file:
329
330
  reader = PyPDF2.PdfReader(file)
330
-
331
+
331
332
  # Extract original metadata
332
333
  if reader.metadata:
333
334
  original_metadata = dict(reader.metadata)
334
-
335
+
335
336
  # Create new PDF writer
336
337
  writer = PyPDF2.PdfWriter()
337
-
338
+
338
339
  # Copy pages without metadata
339
340
  for page_num in range(len(reader.pages)):
340
341
  page = reader.pages[page_num]
341
342
  writer.add_page(page)
342
-
343
+
343
344
  # Preserve essential metadata if requested
344
345
  if preserve_essential and original_metadata:
345
346
  if '/Title' in original_metadata:
346
347
  preserved['/Title'] = original_metadata['/Title']
347
348
  writer.add_metadata({'/Title': original_metadata['/Title']})
348
349
  if '/Creator' in original_metadata:
349
- preserved['/Creator'] = original_metadata['/Creator']
350
+ preserved['/Creator'] = original_metadata['/Creator']
350
351
  writer.add_metadata({'/Creator': original_metadata['/Creator']})
351
-
352
+
352
353
  # Write the cleaned PDF
353
354
  with open(file_path, 'wb') as output_file:
354
355
  writer.write(output_file)
355
-
356
+
356
357
  return MetadataCleanResult(
357
358
  file_path, success=True,
358
359
  metadata_removed=original_metadata,
359
360
  metadata_preserved=preserved
360
361
  )
361
-
362
+
362
363
  except Exception as e:
363
364
  return MetadataCleanResult(
364
365
  file_path, success=False,
365
366
  error=f"Failed to clean PDF metadata: {str(e)}"
366
367
  )
367
-
368
- def _clean_office_metadata(self, file_path: str, file_ext: str,
368
+
369
+ def _clean_office_metadata(self, file_path: str, file_ext: str,
369
370
  preserve_essential: bool) -> MetadataCleanResult:
370
371
  """Clean metadata from Office documents"""
371
-
372
+
372
373
  if file_ext == '.docx':
373
374
  return self._clean_docx_metadata(file_path, preserve_essential)
374
375
  elif file_ext in ['.xlsx', '.pptx']:
375
376
  # For now, return success but log that full implementation is needed
376
377
  self.logger.warning(f"Limited metadata cleaning for {file_ext} files")
377
378
  return MetadataCleanResult(file_path, success=True)
378
-
379
+
379
380
  return MetadataCleanResult(
380
381
  file_path, success=False,
381
382
  error=f"Office format {file_ext} not yet supported"
382
383
  )
383
-
384
+
384
385
  def _clean_docx_metadata(self, file_path: str, preserve_essential: bool) -> MetadataCleanResult:
385
386
  """Clean metadata from DOCX files"""
386
-
387
+
387
388
  if not DOCX_AVAILABLE:
388
389
  return MetadataCleanResult(
389
390
  file_path, success=False,
390
391
  error="python-docx not available for DOCX processing"
391
392
  )
392
-
393
+
393
394
  try:
394
395
  doc = Document(file_path)
395
-
396
+
396
397
  # Extract original metadata
397
398
  original_metadata = {}
398
399
  core_props = doc.core_properties
399
-
400
- for prop in ['title', 'author', 'subject', 'comments', 'category',
400
+
401
+ for prop in ['title', 'author', 'subject', 'comments', 'category',
401
402
  'created', 'modified', 'last_modified_by', 'keywords']:
402
403
  if hasattr(core_props, prop):
403
404
  value = getattr(core_props, prop)
404
405
  if value is not None and str(value).strip() and str(value) != 'None':
405
406
  original_metadata[prop] = str(value)
406
-
407
+
407
408
  # Clear metadata
408
409
  preserved = {}
409
410
  if preserve_essential and original_metadata:
@@ -411,7 +412,7 @@ class MetadataCleaner:
411
412
  preserved['title'] = original_metadata['title']
412
413
  else:
413
414
  core_props.title = ""
414
-
415
+
415
416
  if 'author' in original_metadata:
416
417
  preserved['author'] = original_metadata['author']
417
418
  else:
@@ -425,45 +426,45 @@ class MetadataCleaner:
425
426
  core_props.category = ""
426
427
  core_props.keywords = ""
427
428
  # Note: created/modified are read-only and managed by the system
428
-
429
+
429
430
  # Save the document
430
431
  doc.save(file_path)
431
-
432
+
432
433
  return MetadataCleanResult(
433
434
  file_path, success=True,
434
435
  metadata_removed=original_metadata,
435
436
  metadata_preserved=preserved
436
437
  )
437
-
438
+
438
439
  except Exception as e:
439
440
  return MetadataCleanResult(
440
441
  file_path, success=False,
441
442
  error=f"Failed to clean DOCX metadata: {str(e)}"
442
443
  )
443
-
444
+
444
445
  def _clean_multimedia_metadata(self, file_path: str, preserve_essential: bool) -> MetadataCleanResult:
445
446
  """Clean metadata from multimedia files"""
446
-
447
+
447
448
  if not MUTAGEN_AVAILABLE:
448
449
  return MetadataCleanResult(
449
450
  file_path, success=False,
450
451
  error="Mutagen not available for multimedia processing"
451
452
  )
452
-
453
+
453
454
  try:
454
455
  audio_file = MutagenFile(file_path)
455
-
456
+
456
457
  if audio_file is None:
457
458
  return MetadataCleanResult(
458
459
  file_path, success=False,
459
460
  error="Unsupported multimedia format"
460
461
  )
461
-
462
+
462
463
  # Extract original metadata
463
464
  original_metadata = {}
464
465
  if hasattr(audio_file, 'tags') and audio_file.tags:
465
466
  original_metadata = dict(audio_file.tags)
466
-
467
+
467
468
  # Extract info metadata
468
469
  if hasattr(audio_file, 'info'):
469
470
  info_dict = {}
@@ -472,7 +473,7 @@ class MetadataCleaner:
472
473
  info_dict[attr] = getattr(audio_file.info, attr)
473
474
  if info_dict:
474
475
  original_metadata.update(info_dict)
475
-
476
+
476
477
  # Preserve essential metadata if requested
477
478
  preserved = {}
478
479
  if preserve_essential and hasattr(audio_file, 'info'):
@@ -480,27 +481,27 @@ class MetadataCleaner:
480
481
  preserved['duration'] = audio_file.info.length
481
482
  if hasattr(audio_file.info, 'bitrate'):
482
483
  preserved['bitrate'] = audio_file.info.bitrate
483
-
484
+
484
485
  # Clear all tags
485
486
  if hasattr(audio_file, 'tags') and audio_file.tags:
486
487
  audio_file.delete() # This removes all metadata tags
487
488
  audio_file.save()
488
-
489
+
489
490
  return MetadataCleanResult(
490
491
  file_path, success=True,
491
492
  metadata_removed=original_metadata,
492
493
  metadata_preserved=preserved
493
494
  )
494
-
495
+
495
496
  except Exception as e:
496
497
  return MetadataCleanResult(
497
498
  file_path, success=False,
498
499
  error=f"Failed to clean multimedia metadata: {str(e)}"
499
500
  )
500
-
501
+
501
502
  def _clean_text_metadata(self, file_path: str, preserve_essential: bool) -> MetadataCleanResult:
502
503
  """Clean metadata from text files (limited metadata available)"""
503
-
504
+
504
505
  try:
505
506
  # Text files have minimal metadata, mainly file system attributes
506
507
  original_metadata = {
@@ -508,12 +509,12 @@ class MetadataCleaner:
508
509
  'created': os.path.getctime(file_path),
509
510
  'modified': os.path.getmtime(file_path)
510
511
  }
511
-
512
+
512
513
  # For text files, we mainly preserve content and basic structure
513
514
  preserved = {}
514
515
  if preserve_essential:
515
516
  preserved['size'] = original_metadata['size']
516
-
517
+
517
518
  # For text files, metadata cleaning is mainly about file system attributes
518
519
  # which are handled at the OS level
519
520
  return MetadataCleanResult(
@@ -521,19 +522,19 @@ class MetadataCleaner:
521
522
  metadata_removed=original_metadata,
522
523
  metadata_preserved=preserved
523
524
  )
524
-
525
+
525
526
  except Exception as e:
526
527
  return MetadataCleanResult(
527
528
  file_path, success=False,
528
529
  error=f"Failed to process text file: {str(e)}"
529
530
  )
530
-
531
+
531
532
  def _extract_metadata(self, file_path: str) -> Dict[str, Any]:
532
533
  """Extract metadata from file for verification purposes"""
533
-
534
+
534
535
  metadata = {}
535
536
  file_ext = Path(file_path).suffix.lower()
536
-
537
+
537
538
  try:
538
539
  if file_ext in ['.jpg', '.jpeg', '.png', '.tiff', '.tif', '.gif'] and PILLOW_AVAILABLE:
539
540
  with Image.open(file_path) as img:
@@ -542,13 +543,13 @@ class MetadataCleaner:
542
543
  for tag_id, value in exif_data.items():
543
544
  tag = TAGS.get(tag_id, tag_id)
544
545
  metadata[tag] = value
545
-
546
+
546
547
  elif file_ext == '.pdf' and PDF_AVAILABLE:
547
548
  with open(file_path, 'rb') as file:
548
549
  reader = PyPDF2.PdfReader(file)
549
550
  if reader.metadata:
550
551
  metadata = dict(reader.metadata)
551
-
552
+
552
553
  elif file_ext == '.docx' and DOCX_AVAILABLE:
553
554
  doc = Document(file_path)
554
555
  core_props = doc.core_properties
@@ -557,39 +558,39 @@ class MetadataCleaner:
557
558
  value = getattr(core_props, prop)
558
559
  if value is not None and str(value).strip() and str(value) != 'None':
559
560
  metadata[prop] = str(value)
560
-
561
+
561
562
  elif file_ext in ['.mp3', '.mp4', '.avi', '.mov'] and MUTAGEN_AVAILABLE:
562
563
  audio_file = MutagenFile(file_path)
563
564
  if audio_file and hasattr(audio_file, 'tags') and audio_file.tags:
564
565
  metadata = dict(audio_file.tags)
565
-
566
+
566
567
  except Exception as e:
567
568
  self.logger.debug(f"Error extracting metadata from {file_path}: {str(e)}")
568
-
569
+
569
570
  return metadata
570
-
571
+
571
572
  def _verify_metadata_removal(self, file_path: str, original_metadata: Dict[str, Any]) -> bool:
572
573
  """Verify that metadata has been successfully removed"""
573
-
574
+
574
575
  current_metadata = self._extract_metadata(file_path)
575
-
576
+
576
577
  # Check if significant metadata has been removed
577
578
  removed_count = 0
578
579
  for key in original_metadata:
579
580
  if key not in current_metadata:
580
581
  removed_count += 1
581
-
582
+
582
583
  # Consider successful if most metadata was removed
583
584
  if not original_metadata:
584
585
  return True # No metadata to remove
585
-
586
+
586
587
  removal_percentage = removed_count / len(original_metadata)
587
588
  return removal_percentage >= 0.8 # 80% or more metadata removed
588
-
589
- def _log_audit(self, file_path: str, result: MetadataCleanResult,
589
+
590
+ def _log_audit(self, file_path: str, result: MetadataCleanResult,
590
591
  original_metadata: Dict[str, Any]) -> None:
591
592
  """Log audit information about the metadata cleaning operation"""
592
-
593
+
593
594
  audit_info = {
594
595
  'file_path': file_path,
595
596
  'success': result.success,
@@ -597,45 +598,45 @@ class MetadataCleaner:
597
598
  'metadata_preserved_count': len(result.metadata_preserved),
598
599
  'original_metadata_count': len(original_metadata),
599
600
  'verified': result.verified,
600
- 'error': result.error
601
+ 'error': result.error,
601
602
  }
602
-
603
+
603
604
  self.logger.info(f"AUDIT: Metadata cleaning operation - {audit_info}")
604
-
605
+
605
606
  if result.success:
606
607
  self.logger.debug(f"AUDIT: Removed metadata keys: {list(result.metadata_removed.keys())}")
607
608
  if result.metadata_preserved:
608
609
  self.logger.debug(f"AUDIT: Preserved metadata keys: {list(result.metadata_preserved.keys())}")
609
-
610
+
610
611
  def get_supported_formats(self) -> List[str]:
611
612
  """Get list of supported file formats"""
612
613
  return sorted(list(self.supported_formats))
613
-
614
+
614
615
  def is_supported_format(self, file_path: str) -> bool:
615
616
  """Check if file format is supported"""
616
617
  file_ext = Path(file_path).suffix.lower()
617
618
  return file_ext in self.supported_formats
618
619
 
619
620
 
620
- def clean_metadata(*file_paths: str, preserve_essential: bool = False,
621
- backup: bool = True, verify: bool = True,
621
+ def clean_metadata(*file_paths: str, preserve_essential: bool = False,
622
+ backup: bool = True, verify: bool = True,
622
623
  logger: Optional[logging.Logger] = None) -> List[MetadataCleanResult]:
623
624
  """
624
625
  Convenience function to clean metadata from files
625
-
626
+
626
627
  Args:
627
628
  *file_paths: Variable number of file paths to clean
628
629
  preserve_essential: Whether to preserve essential metadata
629
630
  backup: Whether to create backups before cleaning
630
631
  verify: Whether to verify metadata removal
631
632
  logger: Optional logger instance
632
-
633
+
633
634
  Returns:
634
635
  List of MetadataCleanResult objects
635
636
  """
636
637
  cleaner = MetadataCleaner(logger=logger)
637
638
  return cleaner.clean_metadata(
638
- list(file_paths),
639
+ list(file_paths),
639
640
  preserve_essential=preserve_essential,
640
641
  backup=backup,
641
642
  verify=verify
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cryptshield
3
- Version: 1.1.0
3
+ Version: 1.1.1
4
4
  Summary: Secure Encryption and Deletion Application
5
5
  Author: Wilmer Martinez
6
6
  License: MIT License
@@ -30,7 +30,7 @@ Project-URL: Documentation, https://github.com/wilmerm/cryptshield?tab=readme-ov
30
30
  Project-URL: Repository, https://github.com/wilmerm/cryptshield
31
31
  Project-URL: Issues, https://github.com/wilmerm/cryptshield/issues
32
32
  Project-URL: Release, https://github.com/wilmerm/cryptshield/releases
33
- Keywords: encryption,deletion,secure,application,python,cryptography,cryptshield,guardian
33
+ Keywords: encryption,deletion,secure,application,python,cryptography,cryptshield,guardian,privacy,security,file,folder,data,protection,safety,safeguard,lock,unlock,erase,wipe,shred,scrub,clean,destroy,confidential,sensitive,information,safekeeping,cybersecurity
34
34
  Classifier: Development Status :: 5 - Production/Stable
35
35
  Classifier: Intended Audience :: Developers
36
36
  Classifier: Topic :: Security :: Cryptography
@@ -46,6 +46,7 @@ Requires-Python: >=3.10
46
46
  Description-Content-Type: text/markdown
47
47
  License-File: LICENSE
48
48
  Requires-Dist: cryptography
49
+ Requires-Dist: Pillow
49
50
  Dynamic: license-file
50
51
 
51
52
  # Secure Encryption, Deletion, and Metadata Cleaning Application
@@ -8,5 +8,6 @@ src/cryptshield/metadata_cleaner.py
8
8
  src/cryptshield.egg-info/PKG-INFO
9
9
  src/cryptshield.egg-info/SOURCES.txt
10
10
  src/cryptshield.egg-info/dependency_links.txt
11
+ src/cryptshield.egg-info/entry_points.txt
11
12
  src/cryptshield.egg-info/requires.txt
12
13
  src/cryptshield.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ cryptshield = cryptshield.cryptshield:main
@@ -1,4 +0,0 @@
1
- __version__ = "1.1.0"
2
-
3
-
4
- from .cryptshield import *
File without changes
File without changes
File without changes