Documentation for the Textpattern plugin smd_token by Stef Dawson follows this short message from our sponsor ;-)
If you like my code and it soothes an otherwise unscratchable itch, feel free to show your appreciation with something from my UK Amazon wish list (or US) or donate to the Stef Dawson community coding pot, either via paypal.me/stefdawson or by following the Donate button below to PayPal. Thanks!
smd_token
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 wander aimlessly through thousands of lines of PHP source code, you’ll need to step into the view source page.
Legacy software
If, for some inexplicable reason, you need last century's version of a plugin, it can probably be found on the plugin archive page.
Experimental software
If you’re feeling brave, or fancy trying something new, you can test out some of my beta code. It can be found on the plugin beta page.