class Digest::Class
This module stands as a base class for digest implementation classes.
Public Class Methods
# File ext/digest/lib/digest.rb, line 40 def self.base64digest(str, *args) [digest(str, *args)].pack('m0') end
Returns the base64 encoded hash value of a given string. The return value is properly padded with '=' and contains no line feeds.
static VALUE rb_digest_class_s_bubblebabble(int argc, VALUE *argv, VALUE klass) { return bubblebabble_str_new(rb_funcall2(klass, id_digest, argc, argv)); }
Returns the BubbleBabble encoded hash value of a given string.
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::Instance#new.digest(string), where extra parameters, if any, are passed through to the constructor and the string is passed to digest().
# File ext/digest/lib/digest.rb, line 33 def self.file(name, *args) new(*args).file(name) end
Creates a digest object and reads a given file, name. Optional arguments are passed to the constructor of the digest class.
p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
static VALUE rb_digest_class_s_hexdigest(int argc, VALUE *argv, VALUE klass) { return hexencode_str_new(rb_funcall2(klass, id_digest, argc, argv)); }
Returns the hex-encoded hash value of a given string. This is almost equivalent to Digest.hexencode(Digest::Class.new(*parameters).digest(string)).
Ruby Core © 1993–2017 Yukihiro Matsumoto
Licensed under the Ruby License.
Ruby Standard Library © contributors
Licensed under their own licenses.