Demo entry 2836183

project

   

Submitted by anonymous on Oct 08, 2015 at 12:01
Language: Python. Code size: 1.8 kB.

import random
while True:
    choice = raw_input('''Encrypt = 'e'
Decrypt = 'd'
Advanced encrypt = 'a'
Exit = 'x'
''')
    if choice == "e":
        name = raw_input("Enter file name: ")
        try:
            first_file = open(name,'r')
            documant = first_file.read()
            password = ""
            for i in range(0,8):
                number = random.randrange(33,126)
                letter = chr(number)
                password = password + letter
            print("Your password is: " + password)
            offset_factor = 0
            temp_offset = 0
            for i in password:
                num = ord(i)
                temp_offset = temp_offset + num
            temp_offset = temp_offset / 8
            offset_factor = temp_offset - 32
            final_documant = ""
            for i in documant:
                if i == " ":
                    final_documant = final_documant + " "
                else:
                    num = ord(i)
                    num = num + offset_factor
                    if num > 126:
                        num = num - 94
                        car = chr(num)
                        final_documant = final_documant + car
            new_file_name = raw_input("Enter the name of the new file: ")
            users_file = open(new_file_name, "w")
            users_file.write(final_documant)
            users_file.close()
        except:
            print("<ERROR>   The file you inputted was invalid.")
    elif choice == "d":
        print("TEMPROARY")
    elif choice == "a":
        print("TEMPORARY")
    elif choice == "x":
        print("Goodbye, have a lovley day")
        break
    else:
        print("<ERROR> You inputted a invalid input")

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).