예제 #1
0
def crypto_test():
    if os.path.exists(data_file):
        file = open(data_file, 'rb')

        try:
            decrypt_data = crypto.decrypt(file.read())
        except:
            print("Wrong key used for existing profile")
            exit()
예제 #2
0
def read_file():
    services = {}

    if os.path.exists(data_file):
        file = open(data_file, 'rb')
        lines = crypto.decrypt(file.read())
        file.close()

        for line in lines.splitlines():
            elements = line.split(";")
            new_service = cls_service.service(elements[0], elements[1], elements[2], elements[3])
            services[elements[0]] = new_service

    return services
예제 #3
0
"""Compresses website's images using TingPNG API for Python."""

from os import path, walk
from modules.crypto import decrypt
from getpass import getpass
import tinify

# an AES-encrypted API token
encrypted_key = b'gAAAAABcR2VvBRCEWDErzAvN6JJz3UHrQlly0N9-FUx58kY366Tt8K89JyA8b8lvLJVx0-46LSR3Z2Pc7w8ho_XHKIa8PtL7HBYv9Uz3HyrpAiD8rcGODA8KzY_3pX-wiDv5KsBRKfj7'
decrypted_key = None

# repeatedly attempt to decrypt until it works
while decrypted_key == None:
    decrypted_key = decrypt(\
        bytes(getpass("Input TinyPNG token password: "******"utf-8"),\
        encrypted_key)

# tinify key is the decrypted decoded API token
tinify.key = decrypted_key.decode("utf-8")

# variables for comparing sizes (before x after)
size_before = 0
size_after = 0

# recursively find all of the images in the root folder and all its subfolders
for root, subdirs, files in walk(path.join("..", "_site", "assets", "images")):
    for file in files:
        if file.endswith(("png", "jpg")):
            file_path = path.join(root, file)
            size_before += path.getsize(file_path)
예제 #4
0
                                                     \|\|   
             Unbreakable Encryption for the Masses.\n """)
# Sanitize input
if len(sys.argv) != 2:
	usage()

# Get mode, take appropriate action
mode = sys.argv[1]
if mode == 'pads':
	pads.printPads()
elif mode == 'generate':
	gen.genPad()
elif mode == 'encrypt':
	pad_exists = pads.printPads('outpad')
	if pad_exists:
		name = input("Please choose an outpad to encrypt your message: ")
		crypto.encrypt(pads.getPad(name, 'outpad'))
		pads.chop(name, 'outpad')
	else:
		print("There are no outpads. Generate one.")
elif mode == 'decrypt':
	pad_exists = pads.printPads('inpad')
	if pad_exists:
		name = input("Please choose an inpad to decrypt your message: ")
		crypto.decrypt(pads.getPad(name, 'inpad'))
		pads.chop(name, 'inpad')
	else:
		print("There are no inpads. Obtain one from a friend.")
else:
	usage()
예제 #5
0
 def recv_client(self, client):
     try:
         recv_data = client.conn.recv(4096)
         print decrypt(recv_data, client.dhkey)
     except Exception as e:
         print 'Error: {}'.format(e)
예제 #6
0
            for root, dirs, files in os.walk(".")
            for name in files]

    # upload all files
    for file in files:
        ftp.storbinary('STOR ' + file, open(file, "rb"))
        print("CREATED FILE: " + file)


# an AES-encrypted IP to the FTP server
encrypted_ip = b'gAAAAABcRxS1mc-1IjZFzPEJAeeyLUsBTHMj909m2mAIDtL1T-3M_DvHbaz2shds5W1QGQnruOXgp7whJskdYhkivm-OhJoS2A=='
decrypted_ip = None

# repeatedly attempt to decrypt the IP
while decrypted_ip is None:
    decrypted_ip = decrypt(bytes(getpass("IP Key: "), "utf-8"), encrypted_ip)

ip = decrypted_ip.decode("utf-8")

# repeatedly attempt to connect to the server
while True:
    login = input("Login: "******"Password: "******"Connected!")
            print(ftp.cwd('www'))

                # remove all content that isn't permanent
                remove_content()