Staging
v0.5.1
https://github.com/python/cpython
Revision 973348427e3e987f42ea8a871e18c8d17b5abf52 authored by Miss Islington (bot) on 24 February 2020, 02:07:33 UTC, committed by GitHub on 24 February 2020, 02:07:33 UTC

Full nested function and class info makes it a module browser.

Co-authored-by: blurb-it[bot] <43283697+blurb-it[bot]@users.noreply.github.com>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
(cherry picked from commit aea045adb8c90394264908670cbc495c5a41b65e)

Co-authored-by: Hakan Çelik <hakancelik96@outlook.com>
1 parent b19f7ec
Raw File
Tip revision: 973348427e3e987f42ea8a871e18c8d17b5abf52 authored by Miss Islington (bot) on 24 February 2020, 02:07:33 UTC
bpo-39654: Update pyclbr doc to reflect additional information returned (GH-18528)
Tip revision: 9733484
_cryptmodule.c
/* cryptmodule.c - by Steve Majewski
 */

#include "Python.h"

#include <sys/types.h>

/* Module crypt */

/*[clinic input]
module crypt
[clinic start generated code]*/
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=c6252cf4f2f2ae81]*/

#include "clinic/_cryptmodule.c.h"

/*[clinic input]
crypt.crypt

    word: str
    salt: str
    /

Hash a *word* with the given *salt* and return the hashed password.

*word* will usually be a user's password.  *salt* (either a random 2 or 16
character string, possibly prefixed with $digit$ to indicate the method)
will be used to perturb the encryption algorithm and produce distinct
results for a given *word*.

[clinic start generated code]*/

static PyObject *
crypt_crypt_impl(PyObject *module, const char *word, const char *salt)
/*[clinic end generated code: output=0512284a03d2803c input=0e8edec9c364352b]*/
{
    char *crypt_result;
#ifdef HAVE_CRYPT_R
    struct crypt_data data;
    memset(&data, 0, sizeof(data));
    crypt_result = crypt_r(word, salt, &data);
#else
    crypt_result = crypt(word, salt);
#endif
    return Py_BuildValue("s", crypt_result);
}


static PyMethodDef crypt_methods[] = {
    CRYPT_CRYPT_METHODDEF
    {NULL,              NULL}           /* sentinel */
};


static struct PyModuleDef cryptmodule = {
    PyModuleDef_HEAD_INIT,
    "_crypt",
    NULL,
    -1,
    crypt_methods,
    NULL,
    NULL,
    NULL,
    NULL
};

PyMODINIT_FUNC
PyInit__crypt(void)
{
    return PyModule_Create(&cryptmodule);
}
back to top