| Class | Digest::Class |
| In: |
digest/digest.c
digest/lib/digest.rb |
| Parent: | Object |
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().
/*
* call-seq:
* Digest::Class.digest(string, *parameters) -> hash_string
*
* 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().
*/
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 hex-encoded hash value of a given string. This is almost equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
/*
* 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));
}
ruby-doc.org is hosted and run by James Britt and Happy Camper Studios, a Ruby application development company in Phoenix, Arizona. Ruby-doc.org was created in 2002 to promote the Ruby language and to help other Ruby hackers.
Documentation content on ruby-doc.org is provided by remarkable members of the Ruby community.
For more information on the Ruby programming language, visit ruby-lang.org.
Want to help improve Ruby's API docs? See Ruby Documentation Guidelines.