Branch data Line data Source code
1 : : /*[clinic input]
2 : : preserve
3 : : [clinic start generated code]*/
4 : :
5 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
6 : : # include "pycore_gc.h" // PyGC_Head
7 : : # include "pycore_runtime.h" // _Py_ID()
8 : : #endif
9 : :
10 : :
11 : : PyDoc_STRVAR(MD5Type_copy__doc__,
12 : : "copy($self, /)\n"
13 : : "--\n"
14 : : "\n"
15 : : "Return a copy of the hash object.");
16 : :
17 : : #define MD5TYPE_COPY_METHODDEF \
18 : : {"copy", _PyCFunction_CAST(MD5Type_copy), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, MD5Type_copy__doc__},
19 : :
20 : : static PyObject *
21 : : MD5Type_copy_impl(MD5object *self, PyTypeObject *cls);
22 : :
23 : : static PyObject *
24 : 0 : MD5Type_copy(MD5object *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
25 : : {
26 [ # # ]: 0 : if (nargs) {
27 : 0 : PyErr_SetString(PyExc_TypeError, "copy() takes no arguments");
28 : 0 : return NULL;
29 : : }
30 : 0 : return MD5Type_copy_impl(self, cls);
31 : : }
32 : :
33 : : PyDoc_STRVAR(MD5Type_digest__doc__,
34 : : "digest($self, /)\n"
35 : : "--\n"
36 : : "\n"
37 : : "Return the digest value as a bytes object.");
38 : :
39 : : #define MD5TYPE_DIGEST_METHODDEF \
40 : : {"digest", (PyCFunction)MD5Type_digest, METH_NOARGS, MD5Type_digest__doc__},
41 : :
42 : : static PyObject *
43 : : MD5Type_digest_impl(MD5object *self);
44 : :
45 : : static PyObject *
46 : 0 : MD5Type_digest(MD5object *self, PyObject *Py_UNUSED(ignored))
47 : : {
48 : 0 : return MD5Type_digest_impl(self);
49 : : }
50 : :
51 : : PyDoc_STRVAR(MD5Type_hexdigest__doc__,
52 : : "hexdigest($self, /)\n"
53 : : "--\n"
54 : : "\n"
55 : : "Return the digest value as a string of hexadecimal digits.");
56 : :
57 : : #define MD5TYPE_HEXDIGEST_METHODDEF \
58 : : {"hexdigest", (PyCFunction)MD5Type_hexdigest, METH_NOARGS, MD5Type_hexdigest__doc__},
59 : :
60 : : static PyObject *
61 : : MD5Type_hexdigest_impl(MD5object *self);
62 : :
63 : : static PyObject *
64 : 0 : MD5Type_hexdigest(MD5object *self, PyObject *Py_UNUSED(ignored))
65 : : {
66 : 0 : return MD5Type_hexdigest_impl(self);
67 : : }
68 : :
69 : : PyDoc_STRVAR(MD5Type_update__doc__,
70 : : "update($self, obj, /)\n"
71 : : "--\n"
72 : : "\n"
73 : : "Update this hash object\'s state with the provided string.");
74 : :
75 : : #define MD5TYPE_UPDATE_METHODDEF \
76 : : {"update", (PyCFunction)MD5Type_update, METH_O, MD5Type_update__doc__},
77 : :
78 : : PyDoc_STRVAR(_md5_md5__doc__,
79 : : "md5($module, /, string=b\'\', *, usedforsecurity=True)\n"
80 : : "--\n"
81 : : "\n"
82 : : "Return a new MD5 hash object; optionally initialized with a string.");
83 : :
84 : : #define _MD5_MD5_METHODDEF \
85 : : {"md5", _PyCFunction_CAST(_md5_md5), METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__},
86 : :
87 : : static PyObject *
88 : : _md5_md5_impl(PyObject *module, PyObject *string, int usedforsecurity);
89 : :
90 : : static PyObject *
91 : 0 : _md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
92 : : {
93 : 0 : PyObject *return_value = NULL;
94 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
95 : :
96 : : #define NUM_KEYWORDS 2
97 : : static struct {
98 : : PyGC_Head _this_is_not_used;
99 : : PyObject_VAR_HEAD
100 : : PyObject *ob_item[NUM_KEYWORDS];
101 : : } _kwtuple = {
102 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
103 : : .ob_item = { &_Py_ID(string), &_Py_ID(usedforsecurity), },
104 : : };
105 : : #undef NUM_KEYWORDS
106 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
107 : :
108 : : #else // !Py_BUILD_CORE
109 : : # define KWTUPLE NULL
110 : : #endif // !Py_BUILD_CORE
111 : :
112 : : static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
113 : : static _PyArg_Parser _parser = {
114 : : .keywords = _keywords,
115 : : .fname = "md5",
116 : : .kwtuple = KWTUPLE,
117 : : };
118 : : #undef KWTUPLE
119 : : PyObject *argsbuf[2];
120 [ # # ]: 0 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
121 : 0 : PyObject *string = NULL;
122 : 0 : int usedforsecurity = 1;
123 : :
124 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
# # # # ]
125 [ # # ]: 0 : if (!args) {
126 : 0 : goto exit;
127 : : }
128 [ # # ]: 0 : if (!noptargs) {
129 : 0 : goto skip_optional_pos;
130 : : }
131 [ # # ]: 0 : if (args[0]) {
132 : 0 : string = args[0];
133 [ # # ]: 0 : if (!--noptargs) {
134 : 0 : goto skip_optional_pos;
135 : : }
136 : : }
137 : 0 : skip_optional_pos:
138 [ # # ]: 0 : if (!noptargs) {
139 : 0 : goto skip_optional_kwonly;
140 : : }
141 : 0 : usedforsecurity = PyObject_IsTrue(args[1]);
142 [ # # ]: 0 : if (usedforsecurity < 0) {
143 : 0 : goto exit;
144 : : }
145 : 0 : skip_optional_kwonly:
146 : 0 : return_value = _md5_md5_impl(module, string, usedforsecurity);
147 : :
148 : 0 : exit:
149 : 0 : return return_value;
150 : : }
151 : : /*[clinic end generated code: output=b4924c9905cc9f34 input=a9049054013a1b77]*/
|