If none is given, returns the resulting hash value of the digest in a hex-encoded form,
keeping the digest’s state.
If a string is given, returns the hash value for the given
string in a hex-encoded form, resetting the digest to the initial state before
and after the process.
static VALUE
rb_digest_instance_hexdigest(int argc, VALUE *argv, VALUE self)
{
VALUE str, value;
if (rb_scan_args(argc, argv, "01", &str) > 0) {
rb_funcall(self, id_reset, 0);
rb_funcall(self, id_update, 1, str);
value = rb_funcall(self, id_finish, 0);
rb_funcall(self, id_reset, 0);
} else {
value = rb_funcall(rb_obj_clone(self), id_finish, 0);
}
return hexencode_str_new(value);
}