/* * call-seq: * digest_obj.hexdigest! -> string * * Returns the resulting hash value and resets the digest to the * initial state. */ static VALUE rb_digest_instance_hexdigest_bang(VALUE self) { VALUE value = rb_funcall(self, id_finish, 0); rb_funcall(self, id_reset, 0); return hexencode_str_new(value); }
/* * call-seq: * digest_obj.hexdigest -> string * digest_obj.hexdigest(string) -> string * * 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); }
static VALUE buffer_s_hexdigest(int argc, VALUE *argv, VALUE klass) { VALUE str; volatile VALUE obj; if (argc < 1) { rb_raise(rb_eArgError, "no data given"); } str = *argv++; argc--; StringValue(str); obj = rb_obj_alloc(klass); rb_obj_call_init(obj, argc, argv); return hexencode_str_new(buffer_digest(1, &str, obj)); }
/* * call-seq: * Digest.hexencode(string) -> hexencoded_string * * Generates a hex-encoded version of a given _string_. */ static VALUE rb_digest_s_hexencode(VALUE klass, VALUE str) { return hexencode_str_new(str); }
/* * call-seq: * Digest::Class.hexdigest(string[, ...]) -> hash_string * * Returns the hex-encoded hash value of a given _string_. This is * almost equivalent to * Digest.hexencode(Digest::Class.new(*parameters).digest(string)). */ static VALUE rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass) { return hexencode_str_new(rb_funcall2(klass, id_digest, argc, argv)); }
static VALUE buffer_to_s(VALUE self) { return hexencode_str_new(buffer_digest(0, 0, self)); }
static VALUE buffer_hexdigest_bang(VALUE self) { return hexencode_str_new(buffer_digest_bang(self)); }
static VALUE buffer_hexdigest(int argc, VALUE *argv, VALUE self) { return hexencode_str_new(buffer_digest(argc, argv, self)); }