Encryption scripts using the module cryptography
The good news is that as far as I can tell, the cryptography is correct (password-based key derivation function, random salt). The bad news is that your code is hard to read, and so it's hard to make sure that it's correct.

Please read PEP 8. It's good advice. The first thing one sees is 62 lines and not a single blank line. Use blank lines between function definitions. And on a related note, use auxiliary functions with a clearly-defined task. Avoid very long lines (80 columns maximum is a good idea), and break up long chains like Fernet(base64.urlsafe_b64encode(kdf.derive(getpass.getpass("Password to use: ").encode()))).encrypt(script.encode())) into manageable pieces. Because the code is hard to read, don't expect a complete review.


def exitmsg(msg):
    print(msg)
    input("Press ENTER to exit")
    sys.exit()



Don't require the user to press a key to exit the program. And don't print anything when you don't have anything to say. Standard output is for program output and standard error is for useful messages. This function doesn't do anything useful. Replace exitmsg(msg) by sys.exit().


    def input(string):



Don't override standard functions.


    exitmsg("cryptography not installed install it with pip install cryptography via cmd or powershell (On Windows)")



punctuation is important your message is incomprehensible language is not just a bunch of words thrown together


        exitmsg("Wrong password (-:")



Print error messages to standard error, not standard output. And when there's an error, exit with a nonzero status.


loc = input("Script to use: ")



Don't read script arguments from standard input. Read them from sys.argv. That's what it's for.


try:
    exec(…)
except Exception as ex:
    if(type(ex).__name__ == "InvalidToken"):
        exitmsg("Wrong password (-:")
    print(ex)



You're reporting a “wrong password” error for a certain class of errors. It's not clear to me what you're trying to do with InvalidToken. Rather than hope that the wrong key will result in a particular kind of parse error, start the ciphertext with a known value and check that known value. Since you know that the ciphertext is Python code, start the ciphertext wih a Python comment line.

plaintext = fernet.decrypt(ciphertext)
if not ciphertext.startswith('# OfficialNoob PasswordScriptLocker ciphertext version 000000001\n'):
    raise IncorrectPassword


And once again, error messages go on standard error, and the script must exit with a nonzero status on error.



Of course the whole thing is pretty pointless. Entering a password on each use of the script would be annoying. Using gpg to decrypt the script once and for all would be more flexible (you can use keys instead of a password), more convenient, and more secure (less risk of implementation errors).