]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Modules/cryptmodule.c
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Modules / cryptmodule.c
CommitLineData
4710c53d 1/* cryptmodule.c - by Steve Majewski\r
2 */\r
3\r
4#include "Python.h"\r
5\r
6#include <sys/types.h>\r
7\r
8#ifdef __VMS\r
9#include <openssl/des.h>\r
10#endif\r
11\r
12/* Module crypt */\r
13\r
14\r
15static PyObject *crypt_crypt(PyObject *self, PyObject *args)\r
16{\r
17 char *word, *salt;\r
18#ifndef __VMS\r
19 extern char * crypt(const char *, const char *);\r
20#endif\r
21\r
22 if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) {\r
23 return NULL;\r
24 }\r
25 /* On some platforms (AtheOS) crypt returns NULL for an invalid\r
26 salt. Return None in that case. XXX Maybe raise an exception? */\r
27 return Py_BuildValue("s", crypt(word, salt));\r
28\r
29}\r
30\r
31PyDoc_STRVAR(crypt_crypt__doc__,\r
32"crypt(word, salt) -> string\n\\r
33word will usually be a user's password. salt is a 2-character string\n\\r
34which will be used to select one of 4096 variations of DES. The characters\n\\r
35in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\\r
36the hashed password as a string, which will be composed of characters from\n\\r
37the same alphabet as the salt.");\r
38\r
39\r
40static PyMethodDef crypt_methods[] = {\r
41 {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__},\r
42 {NULL, NULL} /* sentinel */\r
43};\r
44\r
45PyMODINIT_FUNC\r
46initcrypt(void)\r
47{\r
48 Py_InitModule("crypt", crypt_methods);\r
49}\r