=head1 Crypto handlers Like with the L, ermyth has modular crypto facilities. =head2 Writing a new crypto handler Include the interface header #include "atheme.h" #include Add the mandatory rcsid line static char const rcsid[] = "$Id: crypto.pod,v 1.1 2007/08/28 17:14:42 pippijn Exp $"; Define the handler namespace crypto { struct mycrypt : handler { mycrypt () { crypto_module_loaded = true; } virtual ~mycrypt () { crypto_module_loaded = false; } virtual char const *crypt (char const * const key, char const * const salt); }; char const * mycrypt::crypt (char const * const key, char const * const salt) { // Our example merely reverses the string as encryption. std::reverse (key, key + strlen (key)); return key; } } // namespace crypto Register the handler #define FACREG_TYPE crypto::mycrypt #define FACREG_TYPE_NAME "mycrypt" #define FACREG_INTERFACE_TYPE crypto::handler #include =head2 Using the handler Now, we can load our crypto handler with the C configuration directive: crypto "mycrypt"; Encrypting a string is as simple as invoking C<< crypter->crypt ("somestring", "salt") >>. Our simple crypter doesn't use the salt, it just reverses the string and returns "gnirtsemos".