title: EncryptionMechanism
tags: docs mechanism

TiddlyWiki5 allows the entire content of a TiddlyWiki HTML file to be encrypted with the Stanford JavaScript Crypto Library. Opening an encrypted TiddlyWiki in the browser prompts for a password before decrypting and displaying the content.

The EncryptionMechanism is implemented with the following elements:

* A crypto "password vault" within the BootMechanism that holds the current encryption password
* The ability of the BootMechanism to read a block of encrypted tiddlers from the TiddlyWiki file, to prompt the user for a password, and to decrypt the tiddlers
* Handlers for the messages SetPasswordMessage and ClearPasswordMessage that handle the user interface for password changes
* The `<$encrypt>` widget within the main file template that encrypts a filtered list of tiddlers with the currently held password
* The [[$:/isEncrypted]] tiddler that contains "yes" or "no" according to whether there is a password in the password vault
** The availability of this tiddler allows the RevealWidget to be used to selectively display user interface elements according to whether encryption is in force
* The [[$:/snippets/encryptionstatus]] snippet that displays the current encryption status
