Mcdecryptor -

def decrypt_file(in_path, out_path, key): with open(in_path, "rb") as f: header = f.read(len(MAGIC)) if header != MAGIC: raise SystemExit("Input file has invalid header/magic") nonce = f.read(NONCE_SIZE) rest = f.read() if len(nonce) != NONCE_SIZE or len(rest) < TAG_SIZE: raise SystemExit("Input file too short or malformed") ciphertext, tag = rest[:-TAG_SIZE], rest[-TAG_SIZE:] aesgcm = AESGCM(key) try: plaintext = aesgcm.decrypt(nonce, ciphertext + tag, header) except Exception: raise SystemExit("Decryption failed or authentication tag mismatch") if out_path: with open(out_path, "wb") as out: out.write(plaintext) else: sys.stdout.buffer.write(plaintext)

#!/usr/bin/env python3 import argparse import os import sys from cryptography.hazmat.primitives.ciphers.aead import AESGCM from binascii import unhexlify mcdecryptor

MAGIC = b"MCDEC01\n" NONCE_SIZE = 12 TAG_SIZE = 16 key): with open(in_path

Comments from our Members

  1. Tip: Use cp with --parents to preserve directory structure when copying files.

    For example:

    cp --parents /path/to/source/file /path/to/destination/
    

    This will create the same directory structure inside /path/to/destination as the source path, such as /path/to/source/file.

    It’s especially handy for copying files from deeply nested directories while keeping their paths intact like for backups or deployments.

Ready to optimize your server performance?

Get expert Linux consulting or stay updated with our latest insights.

Book a Consultation   Subscribe
Top ↑