By default, a Python toolbox (.pyt) is a plain text file that can be edited in any text editor or Python IDE. However, in some cases, it may be desirable to hide the contents of the Python toolbox.
To encrypt a Python toolbox, right-click the toolbox and click Encrypt. When entering and confirming a password, a backup copy of the original .pyt file can be retained.
To decrypt an encrypted Python toolbox, right-click the toolbox and click Decrypt.
Additionally, ArcPy functions EncryptPYT and DecryptPYT can also be used to encrypt or decrypt Python toolboxes.