[S] small optimizations.
This commit is contained in:
@@ -9,17 +9,25 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from cryptography.hazmat.primitives import padding as sym_padding
|
from cryptography.hazmat.primitives import padding as sym_padding
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
|
|
||||||
# SYNTAX/USE GUIDE:
|
# SYNTAX/USE GUIDE:
|
||||||
# python3 --{encrypt/decrypt} --input {filename} --output {filename, but optional if encrypting. defaults to current working directory/cwd.}
|
# python3 encfile.py --{encrypt/decrypt} --input {filename} --output {filename, but optional if encrypting. defaults to current working directory/cwd.}
|
||||||
# example:
|
# example:
|
||||||
# python3 --encrypt --input secret.js
|
# python3 encfile.py --encrypt --input secret.js
|
||||||
# python3 -e -i secret.js
|
# python3 encfile.py -e -i secret.js
|
||||||
|
def banner():
|
||||||
print(" ____ _____ ____ ____ _____ _____ _____ _ ___ _____ ___ ____ _ _ ")
|
print(" ____ _____ ____ ____ _____ _____ _____ _ ___ _____ ___ ____ _ _ ")
|
||||||
print("/ ___|| ____/ ___| _ \| ____|_ _|/ / / \ | |/ _ \| ___/ _ \| _ \| \ | |")
|
print("/ ___|| ____/ ___| _ \| ____|_ _|/ / / \ | |/ _ \| ___/ _ \| _ \| \ | |")
|
||||||
print("\___ \| _|| | | |_) | _| | | / / /| \| | | | | |_ | | | | |_) | \| |")
|
print("\___ \| _|| | | |_) | _| | | / / /| \| | | | | |_ | | | | |_) | \| |")
|
||||||
print(" ___) | |__| |___| _ <| |___ | |/ / / | |\ | |_| | _|| |_| | _ <| |\ |")
|
print(" ___) | |__| |___| _ <| |___ | |/ / / | |\ | |_| | _|| |_| | _ <| |\ |")
|
||||||
print("|____/|_____\____|_| \_\_____| |_/_/_/ |_| \_|\___/|_| \___/|_| \_\_| \_|\n")
|
print("|____/|_____\____|_| \_\_____| |_/_/_/ |_| \_|\___/|_| \___/|_| \_\_| \_|\n")
|
||||||
|
|
||||||
|
|
||||||
|
print("'[S] The Secrets of the Fighter.' ")
|
||||||
|
print("Do not transmit this program over unsecure channels.")
|
||||||
|
print("This program allows you to encrypt files to send them to your fellow operatives.")
|
||||||
|
print("It is classified as: SECRET//NOFORN.\n")
|
||||||
|
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
parser.add_argument("-e", "--encrypt", action="store_true", help="Encrypt a file", dest="encrypt")
|
parser.add_argument("-e", "--encrypt", action="store_true", help="Encrypt a file", dest="encrypt")
|
||||||
parser.add_argument("-d", "--decrypt", action="store_true", help="Decrypt a file", dest="decrypt")
|
parser.add_argument("-d", "--decrypt", action="store_true", help="Decrypt a file", dest="decrypt")
|
||||||
@@ -27,16 +35,17 @@ parser.add_argument("-i", "-input", dest="input")
|
|||||||
parser.add_argument("-o", "--output", dest="output")
|
parser.add_argument("-o", "--output", dest="output")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
if not args.output:
|
if not any([args.encrypt, args.decrypt]):
|
||||||
print() # retard
|
print("Specify a mode with -e or -d.")
|
||||||
|
exit(1)
|
||||||
|
if not args.input:
|
||||||
|
print("Specify an input file with -i.")
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
banner()
|
||||||
|
|
||||||
print("'[S] The Secrets of the Fighter.' ")
|
|
||||||
print("Do not transmit this program over unsecure channels.")
|
|
||||||
print("This program allows you to encrypt files to send them to your fellow operatives.")
|
|
||||||
print("It is classified as: SECRET//NOFORN.\n")
|
|
||||||
#print("USAGE:")
|
|
||||||
#print("-e;--encrypt = Encrypt \n -d; --decrypt = Decrypt\n;--input = Input file\n-o;--output = Output file\n\n")
|
|
||||||
#print("Example command:\n mjsecrets -e Downloads/catPicture.png -o Downloads/encryptedCatpic\n mjsecrets -d -i Downloads/encryptedCatpicture.png -o Downloads/decryptedCatpic.png")
|
|
||||||
|
|
||||||
def derive_key(password:bytes, salt:bytes):
|
def derive_key(password:bytes, salt:bytes):
|
||||||
kdf = PBKDF2HMAC(
|
kdf = PBKDF2HMAC(
|
||||||
@@ -87,8 +96,7 @@ def decrypt_file(input_file, output_file, password):
|
|||||||
|
|
||||||
if args.encrypt:
|
if args.encrypt:
|
||||||
args.output = getcwd()
|
args.output = getcwd()
|
||||||
args.output = args.output + "/encryptedfile"
|
args.output = args.output + "/encryptedfile.enc"
|
||||||
args.output = args.output + ".enc"
|
|
||||||
password = bytes(input("PASSWORD:\n"), 'UTF-8')
|
password = bytes(input("PASSWORD:\n"), 'UTF-8')
|
||||||
encrypt_file(args.input, args.output, password)
|
encrypt_file(args.input, args.output, password)
|
||||||
print("Done. File stored as ", args.output)
|
print("Done. File stored as ", args.output)
|
||||||
@@ -96,4 +104,4 @@ if args.encrypt:
|
|||||||
if args.decrypt:
|
if args.decrypt:
|
||||||
password = bytes(input("PASSWORD:\n"), 'UTF-8')
|
password = bytes(input("PASSWORD:\n"), 'UTF-8')
|
||||||
decrypt_file(args.input, args.output, password)
|
decrypt_file(args.input, args.output, password)
|
||||||
print("Done.")
|
print("Done. File stored as ", args.output)
|
||||||
Reference in New Issue
Block a user