]>
Commit | Line | Data |
---|---|---|
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 | |
15 | static 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 | |
31 | PyDoc_STRVAR(crypt_crypt__doc__,\r | |
32 | "crypt(word, salt) -> string\n\\r | |
33 | word will usually be a user's password. salt is a 2-character string\n\\r | |
34 | which will be used to select one of 4096 variations of DES. The characters\n\\r | |
35 | in salt must be either \".\", \"/\", or an alphanumeric character. Returns\n\\r | |
36 | the hashed password as a string, which will be composed of characters from\n\\r | |
37 | the same alphabet as the salt.");\r | |
38 | \r | |
39 | \r | |
40 | static PyMethodDef crypt_methods[] = {\r | |
41 | {"crypt", crypt_crypt, METH_VARARGS, crypt_crypt__doc__},\r | |
42 | {NULL, NULL} /* sentinel */\r | |
43 | };\r | |
44 | \r | |
45 | PyMODINIT_FUNC\r | |
46 | initcrypt(void)\r | |
47 | {\r | |
48 | Py_InitModule("crypt", crypt_methods);\r | |
49 | }\r |