Value BuiltinClass<Md5>::callclass(BuiltinArgs& args) { args.usage("usage: Md5(@strings)"); Md5* a = new BuiltinInstance<Md5>(); if (! args.hasUnnamed()) return a; while (Value x = args.getNextUnnamed()) a->update(x.gcstr()); return new SuString(a->value()); }
void testHash () { char out[33]; md5->init (); md5->update (msg, strlen (msg)); char *ret = md5->end (out); CPPUNIT_ASSERT_EQUAL (ret, &out[0]); CPPUNIT_ASSERT_EQUAL (memcmp (expected, out, 32), 0); }
void testHashMemBuf () { MemBuf buffer; char out[33]; buffer << msg; md5->init (); md5->update (buffer); char *ret = md5->end (out); CPPUNIT_ASSERT_EQUAL (ret, &out[0]); CPPUNIT_ASSERT_EQUAL (memcmp (expected, out, 32), 0); }