Skip to content

Commit 7d2ae10

Browse files
committed
Make hash function available again
1 parent 44bd3f3 commit 7d2ae10

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

main.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -148,35 +148,11 @@ PyDoc_STRVAR(copy_doc,
148148
Return a copy (``clone'') of the whirlpool object.");
149149

150150

151-
// TODO Mark deprecated
152-
static PyObject *
153-
whirlpool_hash(PyObject *self, PyObject *args) {
154-
struct NESSIEstruct w;
155-
unsigned char digest[DIGESTBYTES];
156-
Py_ssize_t data_size;
157-
unsigned char *data;
158-
159-
160-
if(!PyArg_ParseTuple(args, "s#", &data, &data_size))
161-
return NULL;
162-
163-
NESSIEinit(&w);
164-
NESSIEadd(data, data_size*8, &w);
165-
NESSIEfinalize(&w, digest);
166-
167-
return Py_BuildValue("s#", digest, DIGESTBYTES);
168-
}
169-
170-
PyDoc_STRVAR(hash_doc,
171-
"Hash with whirlpool algorithm.");
172-
173-
174151
PyMethodDef whirlpool_methods[] = {
175152
{"update", (PyCFunction)whirlpool_update, METH_VARARGS, update_doc},
176153
{"digest", (PyCFunction)whirlpool_digest, METH_NOARGS, digest_doc},
177154
{"hexdigest", (PyCFunction)whirlpool_hexdigest, METH_NOARGS, hexdigest_doc},
178155
{"copy", (PyCFunction)whirlpool_copy, METH_NOARGS, copy_doc},
179-
{"hash", (PyCFunction)whirlpool_hash, METH_VARARGS, hash_doc},
180156
{NULL, NULL} /* sentinel */
181157
};
182158

@@ -286,10 +262,34 @@ Return a new whirlpool object. If arg is present, the method call update(arg)\n\
286262
is made.");
287263

288264

265+
// TODO Mark deprecated
266+
static PyObject *
267+
whirlpool_hash(PyObject *self, PyObject *args) {
268+
struct NESSIEstruct w;
269+
unsigned char digest[DIGESTBYTES];
270+
Py_ssize_t data_size;
271+
unsigned char *data;
272+
273+
274+
if(!PyArg_ParseTuple(args, "s#", &data, &data_size))
275+
return NULL;
276+
277+
NESSIEinit(&w);
278+
NESSIEadd(data, data_size*8, &w);
279+
NESSIEfinalize(&w, digest);
280+
281+
return Py_BuildValue("s#", digest, DIGESTBYTES);
282+
}
283+
284+
PyDoc_STRVAR(hash_doc,
285+
"Hash with whirlpool algorithm.");
286+
287+
289288
/* List of functions exported by this module */
290289

291290
static PyMethodDef whirlpool_functions[] = {
292-
{"new", (PyCFunction)whirlpool_new, METH_VARARGS, new_doc},
291+
{"new", (PyCFunction)whirlpool_new, METH_VARARGS, new_doc},
292+
{"hash", (PyCFunction)whirlpool_hash, METH_VARARGS, hash_doc},
293293
{NULL, NULL} /* sentinel */
294294
};
295295

0 commit comments

Comments
 (0)