MCPcopy Create free account
hub / github.com/dedsec1121fk/DedSec / aesgcm_decrypt_generator

Function aesgcm_decrypt_generator

Scripts/ButSystem.py:570–602  ·  view source on GitHub ↗

aesgcm_decrypt_generator. Cryptography helper for encrypting/decrypting application data. This docstring was expanded to make future maintenance easier. Args: src_path: Parameter. Returns: Varies.

(src_path: str)

Source from the content-addressed store, hash-verified

568 return None
569
570def _save_plain_upload(file_storage, tmp_path: str) -> int:
571 """Save uploaded file to disk quickly (plain) and return size.
572
573 Speed notes:
574 - Prefer Werkzeug's built-in `save()` which streams efficiently to disk.
575 - Fallback to a large-buffer copy for environments where `save()` misbehaves.
576 """
577 os.makedirs(os.path.dirname(tmp_path), exist_ok=True)
578
579 # Fast path: Werkzeug's streaming save (usually the quickest).
580 try:
581 file_storage.save(tmp_path)
582 return int(os.path.getsize(tmp_path))
583 except Exception:
584 pass
585
586 # Fallback: manual copy with a large buffer (minimize Python overhead).
587 size = 0
588 try:
589 try:
590 file_storage.stream.seek(0)
591 except Exception:
592 pass
593 with open(tmp_path, "wb") as out:
594 shutil.copyfileobj(file_storage.stream, out, length=8 * 1024 * 1024) # 8 MiB buffer
595 size = int(os.path.getsize(tmp_path))
596 except Exception:
597 # Last resort: try save again (some backends reset stream after failure)
598 file_storage.save(tmp_path)
599 size = int(os.path.getsize(tmp_path))
600 return int(size)
601
602def _bg_encrypt_file(tmp_plain: str, out_enc: str, finalize_fn):
603 """Encrypt tmp_plain -> out_enc in a background thread, then call finalize_fn(success:bool, err:str|None)."""
604 def worker():
605 """worker.

Callers 14

profile_picFunction · 0.70
downloadFunction · 0.70
view_fileFunction · 0.70
dm_file_streamFunction · 0.70
dm_file_downloadFunction · 0.70
discussion_file_streamFunction · 0.70
discussion_file_downloadFunction · 0.70
discussion_voice_streamFunction · 0.70
dm_voice_streamFunction · 0.70
group_voice_streamFunction · 0.70
profiler_exportFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected