Password protect script

Is there a way to have a user be prompted for a password to open a file? I am trying to protect a bash script from being changed. Thank you :).

Remove write access from the script and have it located in a directory the users don't have write access to.

If the user has root and is misusing it, use auditing to figure out who doesn't deserve root access.

Hopefully you don't allow direct root logins.

Encryption does not work that way.

If they couldn't open the file, they wouldn't be able to run it either.

You have to frontend its execution somehow. Place the script somewhere where the user has *no* access and frontend it using something like sudo that *can* access it.

Changes how you run it, have to use sudo. You can build your own frontend (e.g compiled C program) if you don't like sudo.