blob: c109f9efec6b604ad3a9eafd644983159a86100c [file] [log] [blame]
Serhiy Storchaka1009bf12015-04-03 23:53:51 +03001/*[clinic input]
2preserve
3[clinic start generated code]*/
4
5PyDoc_STRVAR(MD5Type_copy__doc__,
6"copy($self, /)\n"
7"--\n"
8"\n"
9"Return a copy of the hash object.");
10
11#define MD5TYPE_COPY_METHODDEF \
12 {"copy", (PyCFunction)MD5Type_copy, METH_NOARGS, MD5Type_copy__doc__},
13
14static PyObject *
15MD5Type_copy_impl(MD5object *self);
16
17static PyObject *
18MD5Type_copy(MD5object *self, PyObject *Py_UNUSED(ignored))
19{
20 return MD5Type_copy_impl(self);
21}
22
23PyDoc_STRVAR(MD5Type_digest__doc__,
24"digest($self, /)\n"
25"--\n"
26"\n"
Srinivas Thatiparthy (శ్రీనివాస్ తాటిపర్తి)f192aeb2018-10-19 23:12:53 +053027"Return the digest value as a bytes object.");
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030028
29#define MD5TYPE_DIGEST_METHODDEF \
30 {"digest", (PyCFunction)MD5Type_digest, METH_NOARGS, MD5Type_digest__doc__},
31
32static PyObject *
33MD5Type_digest_impl(MD5object *self);
34
35static PyObject *
36MD5Type_digest(MD5object *self, PyObject *Py_UNUSED(ignored))
37{
38 return MD5Type_digest_impl(self);
39}
40
41PyDoc_STRVAR(MD5Type_hexdigest__doc__,
42"hexdigest($self, /)\n"
43"--\n"
44"\n"
45"Return the digest value as a string of hexadecimal digits.");
46
47#define MD5TYPE_HEXDIGEST_METHODDEF \
48 {"hexdigest", (PyCFunction)MD5Type_hexdigest, METH_NOARGS, MD5Type_hexdigest__doc__},
49
50static PyObject *
51MD5Type_hexdigest_impl(MD5object *self);
52
53static PyObject *
54MD5Type_hexdigest(MD5object *self, PyObject *Py_UNUSED(ignored))
55{
56 return MD5Type_hexdigest_impl(self);
57}
58
59PyDoc_STRVAR(MD5Type_update__doc__,
60"update($self, obj, /)\n"
61"--\n"
62"\n"
63"Update this hash object\'s state with the provided string.");
64
65#define MD5TYPE_UPDATE_METHODDEF \
66 {"update", (PyCFunction)MD5Type_update, METH_O, MD5Type_update__doc__},
67
68PyDoc_STRVAR(_md5_md5__doc__,
Christian Heimes7cad53e2019-09-13 02:30:00 +020069"md5($module, /, string=b\'\', *, usedforsecurity=True)\n"
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030070"--\n"
71"\n"
72"Return a new MD5 hash object; optionally initialized with a string.");
73
74#define _MD5_MD5_METHODDEF \
Serhiy Storchaka4a934d42018-11-27 11:27:36 +020075 {"md5", (PyCFunction)(void(*)(void))_md5_md5, METH_FASTCALL|METH_KEYWORDS, _md5_md5__doc__},
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030076
77static PyObject *
Christian Heimes7cad53e2019-09-13 02:30:00 +020078_md5_md5_impl(PyObject *module, PyObject *string, int usedforsecurity);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030079
80static PyObject *
Serhiy Storchakaa5552f02017-12-15 13:11:11 +020081_md5_md5(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030082{
83 PyObject *return_value = NULL;
Christian Heimes7cad53e2019-09-13 02:30:00 +020084 static const char * const _keywords[] = {"string", "usedforsecurity", NULL};
Serhiy Storchaka31913912019-03-14 10:32:22 +020085 static _PyArg_Parser _parser = {NULL, _keywords, "md5", 0};
Christian Heimes7cad53e2019-09-13 02:30:00 +020086 PyObject *argsbuf[2];
Serhiy Storchaka31913912019-03-14 10:32:22 +020087 Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030088 PyObject *string = NULL;
Christian Heimes7cad53e2019-09-13 02:30:00 +020089 int usedforsecurity = 1;
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030090
Serhiy Storchaka31913912019-03-14 10:32:22 +020091 args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
92 if (!args) {
Serhiy Storchaka1009bf12015-04-03 23:53:51 +030093 goto exit;
Serhiy Storchaka5dee6552016-06-09 16:16:06 +030094 }
Serhiy Storchaka31913912019-03-14 10:32:22 +020095 if (!noptargs) {
96 goto skip_optional_pos;
97 }
Christian Heimes7cad53e2019-09-13 02:30:00 +020098 if (args[0]) {
99 string = args[0];
100 if (!--noptargs) {
101 goto skip_optional_pos;
102 }
103 }
Serhiy Storchaka31913912019-03-14 10:32:22 +0200104skip_optional_pos:
Christian Heimes7cad53e2019-09-13 02:30:00 +0200105 if (!noptargs) {
106 goto skip_optional_kwonly;
107 }
108 usedforsecurity = PyObject_IsTrue(args[1]);
109 if (usedforsecurity < 0) {
110 goto exit;
111 }
112skip_optional_kwonly:
113 return_value = _md5_md5_impl(module, string, usedforsecurity);
Serhiy Storchaka1009bf12015-04-03 23:53:51 +0300114
115exit:
116 return return_value;
117}
Christian Heimes7cad53e2019-09-13 02:30:00 +0200118/*[clinic end generated code: output=dbe3abc60086f3ef input=a9049054013a1b77]*/