Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 1 | /*[clinic input] |
| 2 | preserve |
| 3 | [clinic start generated code]*/ |
| 4 | |
| 5 | PyDoc_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 | |
| 19 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 20 | crypt_crypt_impl(PyObject *module, const char *word, const char *salt); |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 21 | |
| 22 | static PyObject * |
Serhiy Storchaka | 1a2b24f | 2016-07-07 17:35:15 +0300 | [diff] [blame] | 23 | crypt_crypt(PyObject *module, PyObject *args) |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 24 | { |
| 25 | PyObject *return_value = NULL; |
| 26 | const char *word; |
| 27 | const char *salt; |
| 28 | |
Serhiy Storchaka | 247789c | 2015-04-24 00:40:51 +0300 | [diff] [blame] | 29 | if (!PyArg_ParseTuple(args, "ss:crypt", |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 30 | &word, &salt)) { |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 31 | goto exit; |
Serhiy Storchaka | 5dee655 | 2016-06-09 16:16:06 +0300 | [diff] [blame] | 32 | } |
Serhiy Storchaka | 1009bf1 | 2015-04-03 23:53:51 +0300 | [diff] [blame] | 33 | return_value = crypt_crypt_impl(module, word, salt); |
| 34 | |
| 35 | exit: |
| 36 | return return_value; |
| 37 | } |
Serhiy Storchaka | 2954f83 | 2016-07-07 18:20:03 +0300 | [diff] [blame] | 38 | /*[clinic end generated code: output=8dfc88264e662df4 input=a9049054013a1b77]*/ |