blob: a3c371cbaa826b4b499e4a30cdd3e5865a766514 [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(crypt_crypt__doc__,
6"crypt($module, word, salt, /)\n"
7"--\n"
8"\n"
9"Hash a *word* with the given *salt* and return the hashed password.\n"
10"\n"
11"*word* will usually be a user\'s password. *salt* (either a random 2 or 16\n"
12"character string, possibly prefixed with $digit$ to indicate the method)\n"
13"will be used to perturb the encryption algorithm and produce distinct\n"
14"results for a given *word*.");
15
16#define CRYPT_CRYPT_METHODDEF \
17 {"crypt", (PyCFunction)crypt_crypt, METH_VARARGS, crypt_crypt__doc__},
18
19static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030020crypt_crypt_impl(PyObject *module, const char *word, const char *salt);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030021
22static PyObject *
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030023crypt_crypt(PyObject *module, PyObject *args)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030024{
25 PyObject *return_value = NULL;
26 const char *word;
27 const char *salt;
28
Serhiy Storchaka247789c2015-04-24 00:40:51 +030029 if (!PyArg_ParseTuple(args, "ss:crypt",
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030030 &word, &salt))
31 goto exit;
32 return_value = crypt_crypt_impl(module, word, salt);
33
34exit:
35 return return_value;
36}
Serhiy Storchaka1a2b24f2016-07-07 17:35:15 +030037/*[clinic end generated code: output=e0493a9691537690 input=a9049054013a1b77]*/