2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 2006, Digium, Inc.
5 * Copyright (C) 2006, Claude Patry
7 * See http://www.asterisk.org for more information about
8 * the Asterisk project. Please do not directly contact
9 * any of the maintainers of this project for assistance;
10 * the project provides a web site, mailing lists and IRC
11 * channels for your use.
13 * This program is free software, distributed under the terms of
14 * the GNU General Public License Version 2. See the LICENSE file
15 * at the top of the source tree.
20 * \brief SHA1 digest related dialplan functions
22 * \author Claude Patry <cpatry@gmail.com>
27 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
32 #include <sys/types.h>
34 #include "asterisk/module.h"
35 #include "asterisk/channel.h"
36 #include "asterisk/pbx.h"
37 #include "asterisk/logger.h"
38 #include "asterisk/utils.h"
39 #include "asterisk/app.h"
41 static int sha1(struct ast_channel
*chan
, char *cmd
, char *data
,
42 char *buf
, size_t len
)
46 if (ast_strlen_zero(data
)) {
47 ast_log(LOG_WARNING
, "Syntax: SHA1(<data>) - missing argument!\n");
52 ast_sha1_hash(buf
, data
);
55 "Insufficient space to produce SHA1 hash result (%d < 41)\n",
62 static struct ast_custom_function sha1_function
= {
64 .synopsis
= "Computes a SHA1 digest",
65 .syntax
= "SHA1(<data>)",
67 .desc
= "Generate a SHA1 digest via the SHA1 algorythm.\n"
68 " Example: Set(sha1hash=${SHA1(junky)})\n"
69 " Sets the asterisk variable sha1hash to the string '60fa5675b9303eb62f99a9cd47f9f5837d18f9a0'\n"
70 " which is known as his hash\n",
73 static int unload_module(void)
75 return ast_custom_function_unregister(&sha1_function
);
78 static int load_module(void)
80 return ast_custom_function_register(&sha1_function
);
83 AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY
, "SHA-1 computation dialplan function");