blob: 0c9d23744ddb60d2ce8a20cb9f61b2f7ff4d51f6 [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 \
Victor Stinner259f0e42017-01-17 01:35:17 +010017 {"crypt", (PyCFunction)crypt_crypt, METH_FASTCALL, crypt_crypt__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030018
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 *
Victor Stinner259f0e42017-01-17 01:35:17 +010023crypt_crypt(PyObject *module, PyObject **args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030024{
25 PyObject *return_value = NULL;
26 const char *word;
27 const char *salt;
28
Sylvain74453812017-06-10 06:51:48 +020029 if (!_PyArg_NoStackKeywords("crypt", kwnames)) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030030 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030031 }
Victor Stinner259f0e42017-01-17 01:35:17 +010032
Sylvain74453812017-06-10 06:51:48 +020033 if (!_PyArg_ParseStack(args, nargs, "ss:crypt",
34 &word, &salt)) {
Victor Stinner259f0e42017-01-17 01:35:17 +010035 goto exit;
36 }
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030037 return_value = crypt_crypt_impl(module, word, salt);
38
39exit:
40 return return_value;
41}
Sylvain74453812017-06-10 06:51:48 +020042/*[clinic end generated code: output=ebdc6b6a5dec4539 input=a9049054013a1b77]*/