Apple - How does the sudo key symbol work?

I get the key symbol when running read -s in Terminal.

As this seems to work the same for read -s as for sudo, I assume this is a feature of Terminal (to display a key symbol whenever input is requested in silent/hidden mode).

The simplest answer is just write the script without sudo

then tell the user to run it with sudo e.g. sudo script

the script will run with root privileges

`this has the advantage that the user knows what asks for and where the password is used, if in your script you could be taking a copy or leaving it in memory