n: smd_token | v: 0.1.0 | f: /

Documentation for the Textpattern plugin smd_token by Stef Dawson follows this short message from our sponsor ;-)

Plugin list button Plugin download button Compressed plugin download button


Public tag to return a cryptographically secure sequence of characters. Very handy for using inside plugins or CSP headers.

Installation / Uninstallation

Download this plugin and then paste the code from the .txt file into the Textpattern Admin->Plugins panel, install and enable the plugin. For bug reports, please raise an issue.

To uninstall, delete the plugin from the Admin->Plugins panel.

Usage examples

16-character tokens are default therefore to return a 16-character randomly-generated token:

<txp:smd_token />

Display a 24-character randomly-generated token:

<txp:smd_token length="24" />

Display a 12-character randomly-generated token with a prefix:

<txp:smd_token length="12" prefix="nonce-" />

Outputs something like nonce-ab1b7f98175e.

Author / credits

Written by Stef Dawson.

Source code

If you’d rather spend time with the bytes, you’ll need to step into the view source page.

Legacy software

If, for some inexplicable reason, you need an ancient version of a plugin, it can probably be found on the plugin archive page.

Experimental software

If you’re feeling brave, or fancy going bareback, you can test out some of my beta code. It can be found on the plugin beta page.