Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Digest::Class.digest
(::string) -> ::String
Digest::Class.digest(string, *parameters) → hash_string
ext/digest/digest.c
View on GitHub ↗
static VALUE
rb_digest_class_s_digest(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 rb_funcall(obj, id_digest, 1, str);
}
Returns the hash value of a given string. This is equivalent to Digest::Class.new(*parameters).digest(string), where extra parameters, if any, are passed through to the constructor and the string is passed to digest().