return (0);
}
-static PyObject *shakemeth_done(PyObject *me, PyObject *arg)
+static PyObject *shakemeth_done(PyObject *me, PyObject *arg, PyObject *kw)
{
PyObject *rc = 0;
- size_t n;
- if (!PyArg_ParseTuple(arg, "O&:done", convszt, &n)) goto end;
+ size_t n = 100 - SHAKE_H(me)->h.r/2;
+ static const char *const kwlist[] = { "hsz", 0 };
+ if (!PyArg_ParseTupleAndKeywords(arg, kw, "|O&:done", KWLIST, convszt, &n))
+ goto end;
if (shake_check(me, 0)) goto end;
rc = bytestring_pywrap(0, n);
shake_done(SHAKE_H(me), BIN_PTR(rc), n);
#undef METHBUF_
METH (hashstrz, "S.hashstrz(STRING)")
NAMETH(xof, "S.xof()")
- METH (done, "S.done(LEN) -> H")
+ KWMETH(done, "S.done([hsz = CAP]) -> H")
METH (get, "S.get(LEN) -> H")
METH (mask, "S.mask(M) -> C")
#undef METHNAME
## Check the menagerie of random hashing methods.
def mkhash(_):
x = xcls(func = func, perso = perso)
- return x, lambda: x.done(100 - x.rate//2)
+ return x, x.done
me.check_hashbuffer(mkhash)
## Check the state machine tracking.
x = xcls(); me.assertEqual(x.state, "absorb")
x.hash(m); me.assertEqual(x.state, "absorb")
xx = x.copy()
- h = xx.done(100 - x.rate//2)
+ h = xx.done(); me.assertEqual(len(h), 100 - x.rate//2)
me.assertEqual(xx.state, "dead")
me.assertRaises(ValueError, xx.done, 1)
me.assertRaises(ValueError, xx.get, 1)